Bug 1463673 - Add the expected argument to Assert.throws/rejects for toolkit/components/telemetry. r=gfritzsche

MozReview-Commit-ID: KclrG4BfCgp

--HG--
extra : rebase_source : ec3d427a188360822eb29d9db9a15816d49bc9a5
This commit is contained in:
Mark Banner 2018-05-22 19:24:50 +01:00
parent 1115b1e08b
commit 2798fc48dd
5 changed files with 10 additions and 1 deletions

View File

@ -216,6 +216,7 @@ add_task(async function test_archiveCleanup() {
// Check that the pruned pings are not on disk anymore.
for (let prunedInfo of expectedPrunedInfo) {
await Assert.rejects(TelemetryArchive.promiseArchivedPingById(prunedInfo.id),
/TelemetryStorage.loadArchivedPing - no ping with id/,
"Ping " + prunedInfo.id + " should have been pruned.");
const pingPath =
TelemetryStorage._testGetArchivedPingPath(prunedInfo.id, prunedInfo.creationDate, PING_TYPE);

View File

@ -542,6 +542,7 @@ add_task(async function test_sendNewProfile() {
// Check that is not sent with the pingsender during startup.
Assert.throws(() => req.getHeader("X-PingSender-Version"),
/NS_ERROR_NOT_AVAILABLE/,
"Should not have used the pingsender.");
// Make sure that the new-profile ping is sent at shutdown if it wasn't sent before.

View File

@ -266,6 +266,7 @@ add_task(async function test_discardedForSizePending() {
await TelemetryStorage.savePendingPing(OVERSIZED_PING);
// Try to manually load the oversized ping.
await Assert.rejects(TelemetryStorage.loadPendingPing(OVERSIZED_PING_ID),
/loadPendingPing - exceeded the maximum ping size/,
"The oversized ping should have been pruned.");
let ping = await PingServer.promiseNextPing();

View File

@ -420,7 +420,9 @@ add_task(async function test_evictedOnServerErrors() {
Assert.equal(histogramValueCount(histSendTimeFail.snapshot()), 0);
// The ping should not be persisted.
await Assert.rejects(TelemetryStorage.loadPendingPing(pingId), "The ping must not be persisted.");
await Assert.rejects(TelemetryStorage.loadPendingPing(pingId),
/TelemetryStorage.loadPendingPing - no ping with id/,
"The ping must not be persisted.");
// Reset the ping handler and submit a new ping.
PingServer.resetPingHandler();

View File

@ -275,6 +275,7 @@ add_task(async function test_corrupted_pending_pings() {
// Try to load a pending ping which isn't there anymore.
await Assert.rejects(TelemetryStorage.loadPendingPing(pendingPingId),
/PingReadError/,
"Telemetry must fail loading a ping which isn't there");
h = Telemetry.getHistogramById("TELEMETRY_PENDING_LOAD_FAILURE_READ").snapshot();
@ -290,6 +291,7 @@ add_task(async function test_corrupted_pending_pings() {
// Try to load the ping with the corrupted JSON content.
await Assert.rejects(TelemetryStorage.loadPendingPing(pendingPingId),
/PingParseError/,
"Telemetry must fail loading a corrupted ping");
h = Telemetry.getHistogramById("TELEMETRY_PENDING_LOAD_FAILURE_READ").snapshot();
@ -402,6 +404,7 @@ add_task(async function test_pendingPingsQuota() {
// Check that the pruned pings are not on disk anymore.
for (let prunedPingId of expectedPrunedPings) {
await Assert.rejects(TelemetryStorage.loadPendingPing(prunedPingId),
/TelemetryStorage.loadPendingPing - no ping with id/,
"Ping " + prunedPingId + " should have been pruned.");
const pingPath = getSavePathForPingId(prunedPingId);
Assert.ok(!(await OS.File.exists(pingPath)), "The ping should not be on the disk anymore.");
@ -509,6 +512,7 @@ add_task(async function test_pendingPingsQuota() {
// Try to manually load the oversized ping.
await Assert.rejects(TelemetryStorage.loadPendingPing(OVERSIZED_PING_ID),
/loadPendingPing - exceeded the maximum ping size/,
"The oversized ping should have been pruned.");
Assert.ok(!(await OS.File.exists(getSavePathForPingId(OVERSIZED_PING_ID))),
"The ping should not be on the disk anymore.");