diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2018-10-17 20:30:23 +0200 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2018-10-18 05:08:49 -0400 |
commit | 3a226f166fef38829810fb8813b46dee73c83005 (patch) | |
tree | 9b4a3fc598e96f544a59a1dc8eae796713bf17ac /js/metrics_test.ts | |
parent | fd2bb015c721c2db447272b4e9cd47fec353c6e1 (diff) |
add test case for metrics
Diffstat (limited to 'js/metrics_test.ts')
-rw-r--r-- | js/metrics_test.ts | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/js/metrics_test.ts b/js/metrics_test.ts index 6954ae2ce..fd146df2d 100644 --- a/js/metrics_test.ts +++ b/js/metrics_test.ts @@ -1,8 +1,8 @@ // Copyright 2018 the Deno authors. All rights reserved. MIT license. -import { test, assert } from "./test_util.ts"; +import { test, testPerm, assert } from "./test_util.ts"; import * as deno from "deno"; -test(function metrics() { +test(async function metrics() { const m1 = deno.metrics(); assert(m1.opsDispatched > 0); assert(m1.opsCompleted > 0); @@ -13,7 +13,7 @@ test(function metrics() { // Write to stdout to ensure a "data" message gets sent instead of just // control messages. const dataMsg = new Uint8Array([41, 42, 43]); - deno.stdout.write(dataMsg); + await deno.stdout.write(dataMsg); const m2 = deno.metrics(); assert(m2.opsDispatched > m1.opsDispatched); @@ -22,3 +22,23 @@ test(function metrics() { assert(m2.bytesSentData >= m1.bytesSentData + dataMsg.byteLength); assert(m2.bytesReceived > m1.bytesReceived); }); + +testPerm({ write: true }, function metricsUpdatedIfNoResponseSync() { + const filename = deno.makeTempDirSync() + "/test.txt"; + + const data = new Uint8Array([41, 42, 43]); + deno.writeFileSync(filename, data, 0o666); + + const metrics = deno.metrics(); + assert(metrics.opsDispatched === metrics.opsCompleted); +}); + +testPerm({ write: true }, async function metricsUpdatedIfNoResponseAsync() { + const filename = deno.makeTempDirSync() + "/test.txt"; + + const data = new Uint8Array([41, 42, 43]); + await deno.writeFile(filename, data, 0o666); + + const metrics = deno.metrics(); + assert(metrics.opsDispatched === metrics.opsCompleted); +});
\ No newline at end of file |