Skip to content

Commit

Permalink
test: move tests to a folder
Browse files Browse the repository at this point in the history
  • Loading branch information
gabivlj committed Sep 23, 2024
1 parent 4362f90 commit 35d6cbb
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 24 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"deploy": "wrangler publish",
"dev:miniflare": "cross-env NODE_ENV=development wrangler --env dev dev --port 9999 --live-reload",
"typecheck": "tsc",
"test": "vitest --config vitest.config.ts run"
"test": "vitest --config test/vitest.config.ts run"
},
"dependencies": {
"@cfworker/base64url": "^1.12.5",
Expand Down
20 changes: 10 additions & 10 deletions index.test.ts → test/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { afterAll, describe, expect, test } from "vitest";
import { SHA256_PREFIX_LEN, getSHA256 } from "./src/user";
import { TagsList } from "./src/router";
import { Env } from ".";
import { RegistryTokens } from "./src/token";
import { RegistryAuthProtocolTokenPayload } from "./src/auth";
import { registries } from "./src/registry/registry";
import { RegistryHTTPClient } from "./src/registry/http";
import { SHA256_PREFIX_LEN, getSHA256 } from "../src/user";
import { TagsList } from "../src/router";
import { Env } from "..";
import { RegistryTokens } from "../src/token";
import { RegistryAuthProtocolTokenPayload } from "../src/auth";
import { registries } from "../src/registry/registry";
import { RegistryHTTPClient } from "../src/registry/http";
import { encode } from "@cfworker/base64url";
import { ManifestSchema } from "./src/manifest";
import { limit } from "./src/chunk";
import worker from "./index";
import { ManifestSchema } from "../src/manifest";
import { limit } from "../src/chunk";
import worker from "../index";
import { createExecutionContext, env, waitOnExecutionContext } from "cloudflare:test";

async function generateManifest(name: string): Promise<ManifestSchema> {
Expand Down
13 changes: 13 additions & 0 deletions test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"include": ["vitest.config.ts"],
"compilerOptions": {
"strict": true,
"module": "esnext",
"target": "esnext",
"lib": ["esnext"],
"moduleResolution": "bundler",
"noEmit": true,
"skipLibCheck": true,
"allowSyntheticDefaultImports": true
}
}
File renamed without changes.
12 changes: 1 addition & 11 deletions wrangler.test.toml → test/wrangler.test.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "r2-registry"

workers_dev = true
main = "./index.ts"
main = "../index.ts"
compatibility_date = "2024-09-09"
compatibility_flags = ["nodejs_compat"]

Expand All @@ -13,19 +13,9 @@ r2_buckets = [

[env.production.vars]
JWT_REGISTRY_TOKENS_PUBLIC_KEY = ""

# Secrets:
# USERNAME/PASSWORD if you want username/password based auth


## Dev - For local dev using `npx wrangler dev`
[env.dev]
r2_buckets = [{ binding = "REGISTRY", bucket_name = "r2-image-registry-dev" }]

[env.dev.vars]
# REGISTRIES_JSON = "[{ \"registry\": \"http://localhost:9999\", \"password_env\": \"PASSWORD\", \"username\": \"hello\" }]"
USERNAME = "hello"
PASSWORD = "world"
# The necessary secrets are:
# Setup those secrets on .dev.vars in the root of the project
#
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "./tsconfig.base.json",
"include": ["src/**/*.ts", "*.ts"],
"exclude": ["src/**/*.js", "dist/**/*.ts"]
"include": ["src/**/*.ts", "index.ts", "test/index.test.ts"],
"exclude": ["src/**/*.js", "dist/**/*.ts", "test/vitest.config.ts"]
}

0 comments on commit 35d6cbb

Please sign in to comment.