chore: only run KV tests if KV is available (#1794)
This commit is contained in:
@@ -1,13 +1,29 @@
|
|||||||
// Copyright 2023 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2023 the Deno authors. All rights reserved. MIT license.
|
||||||
import kvOAuthPlugin from "$fresh/plugins/kv_oauth.ts";
|
|
||||||
import {
|
import {
|
||||||
assert,
|
assert,
|
||||||
assertArrayIncludes,
|
assertArrayIncludes,
|
||||||
assertNotEquals,
|
assertNotEquals,
|
||||||
} from "$std/testing/asserts.ts";
|
} from "$std/testing/asserts.ts";
|
||||||
import { oauth2Client } from "./plugin_test_utils.ts";
|
import { colors } from "$fresh/src/server/deps.ts";
|
||||||
|
|
||||||
|
// @ts-ignore openKv is only available with --unstable
|
||||||
|
const hasKVEnabled = typeof Deno.openKv === "function";
|
||||||
|
if (!hasKVEnabled) {
|
||||||
|
console.log(
|
||||||
|
colors.yellow(`Skipping Deno KV tests. Pass "--unstable" to run them.`),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Deno.test(
|
||||||
|
{
|
||||||
|
name: "kvOAuthPlugin() works correctly",
|
||||||
|
ignore: !hasKVEnabled,
|
||||||
|
sanitizeResources: false,
|
||||||
|
fn: async (test) => {
|
||||||
|
const { oauth2Client } = await import("./plugin_test_utils.ts");
|
||||||
|
const kvOAuthPlugin =
|
||||||
|
(await import("$fresh/plugins/kv_oauth.ts")).default;
|
||||||
|
|
||||||
Deno.test("kvOAuthPlugin() works correctly", async (test) => {
|
|
||||||
await test.step("with default values", () => {
|
await test.step("with default values", () => {
|
||||||
const plugin = kvOAuthPlugin(oauth2Client);
|
const plugin = kvOAuthPlugin(oauth2Client);
|
||||||
assertNotEquals(plugin.routes, undefined);
|
assertNotEquals(plugin.routes, undefined);
|
||||||
@@ -50,4 +66,6 @@ Deno.test("kvOAuthPlugin() works correctly", async (test) => {
|
|||||||
`/oauth/${providerKey}/signout`,
|
`/oauth/${providerKey}/signout`,
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
});
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user