From f8a1d52a33e2201eddc4c3c12fa0a63e2e6fdbae Mon Sep 17 00:00:00 2001 From: Emily Stark Date: Wed, 28 May 2014 20:58:27 -0700 Subject: [PATCH] Add 'slow' tag to report-stats test --- tools/tests/report-stats.js | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/tools/tests/report-stats.js b/tools/tests/report-stats.js index a6b5c79677..2f93f5246a 100644 --- a/tools/tests/report-stats.js +++ b/tools/tests/report-stats.js @@ -9,7 +9,7 @@ process.env.METEOR_PACKAGE_STATS_SERVER_URL = testStatsServer; // NOTE: This test will fail if your machine's time is skewed by more // than 30 minutes. This is because the `fetchAppPackageUsage` method // works by passing an hour time range. -selftest.define("report-stats", function () { +selftest.define("report-stats", ["slow"], function () { var s = new Sandbox; var run = s.run("create", "foo"); @@ -46,8 +46,23 @@ selftest.define("report-stats", function () { appPackages = stats.getPackagesForAppIdInTest(s.cwd); selftest.expectEqual(appPackages.userId, testUtils.getUserId(s)); - // TODO: - // - opt out + // Add the opt-out package, verify that no stats are recorded for the + // app. + run = s.run("add", "package-stats-opt-out"); + run.waitSecs(15); + run.expectExit(0); + bundleWithFreshIdentifier(s); + appPackages = stats.getPackagesForAppIdInTest(s.cwd); + selftest.expectEqual(appPackages, undefined); + + // Remove the opt-out package, verify that stats get sent again. + run = s.run("remove", "package-stats-opt-out"); + run.waitSecs(15); + run.expectExit(0); + bundle(s); + appPackages = stats.getPackagesForAppIdInTest(s.cwd); + selftest.expectEqual(appPackages.userId, testUtils.getUserId(s)); + selftest.expectEqual(appPackages.packages, stats.packageList(s.cwd)); }); // Bundle the app in the current working directory after deleting its @@ -55,6 +70,12 @@ selftest.define("report-stats", function () { // @param s {Sandbox} var bundleWithFreshIdentifier = function (s) { s.unlink(".meteor/identifier"); + bundle(s); +}; + +// Bundle the app in the current working directory. +// @param s {Sandbox} +var bundle = function (s) { var run = s.run("bundle", "foo.tar.gz"); run.waitSecs(30); run.expectExit(0);