Skip to content

Commit

Permalink
update test to cover env infer
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Dec 6, 2024
1 parent ec1b11f commit 764ec6f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
VITE_UPSTASH_REDIS_REST_URL=https://capital-monkey-22863.upstash.io
VITE_UPSTASH_REDIS_REST_TOKEN=AVlPAAIjcDEyMDEyNzAyYjI4OWI0NzQzOGRjNmNkMWMzMzlmN2IwNXAxMA
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
VITE_UPSTASH_REDIS_REST_URL=
VITE_UPSTASH_REDIS_REST_TOKEN=
2 changes: 1 addition & 1 deletion src/drivers/upstash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface UpstashOptions extends Partial<RedisConfigNodejs> {
const DRIVER_NAME = "upstash";

export default defineDriver<UpstashOptions, Redis>(
(options: UpstashOptions) => {
(options: UpstashOptions = {}) => {
const base = normalizeKey(options?.base);
const r = (...keys: string[]) => joinKeys(base, ...keys);

Expand Down
13 changes: 6 additions & 7 deletions test/drivers/upstash.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ import { describe } from "vitest";
import { testDriver } from "./utils";
import driver from "../../src/drivers/upstash";

const hasEnv =
process.env.UPSTASH_REDIS_REST_URL && process.env.UPSTASH_REDIS_REST_TOKEN;
const url = process.env.VITE_UPSTASH_REDIS_REST_URL;
const token = process.env.VITE_UPSTASH_REDIS_REST_TOKEN;

describe.skipIf(!hasEnv)("drivers: upstash", async () => {
describe.skipIf(!url || !token)("drivers: upstash", async () => {
process.env.UPSTASH_REDIS_REST_URL = url;
process.env.UPSTASH_REDIS_REST_TOKEN = token;
testDriver({
driver: driver({
url: process.env.VITE_UPSTASH_REDIS_REST_URL,
token: process.env.UPSTASH_REDIS_REST_TOKEN,
}),
driver: driver({}),
});
});

0 comments on commit 764ec6f

Please sign in to comment.