diff --git a/test/empty/index.ts b/test/empty/index.ts new file mode 100644 index 0000000..ff8b4c5 --- /dev/null +++ b/test/empty/index.ts @@ -0,0 +1 @@ +export default {}; diff --git a/test/empty/wrangler.toml b/test/empty/wrangler.toml new file mode 100644 index 0000000..4c09785 --- /dev/null +++ b/test/empty/wrangler.toml @@ -0,0 +1,4 @@ +name = "wrangler-action-test" +main = "./index.ts" +compatibility_date = "2023-07-07" +workers_dev = true diff --git a/test/npm/index.ts b/test/npm/index.ts new file mode 100644 index 0000000..a330557 --- /dev/null +++ b/test/npm/index.ts @@ -0,0 +1,26 @@ +type Env = { + SECRET1?: string; + SECRET2?: string; +}; + +export default { + fetch(request: Request, env: Env) { + const url = new URL(request.url); + + if (url.pathname === "/secret-health-check") { + const { SECRET1, SECRET2 } = env; + + if (SECRET1 !== "SECRET_1_VALUE" || SECRET2 !== "SECRET_2_VALUE") { + throw new Error("SECRET1 or SECRET2 is not defined"); + } + + return new Response("OK"); + } + + // @ts-expect-error + return Response.json({ + ...request, + headers: Object.fromEntries(request.headers), + }); + }, +}; diff --git a/test/npm/wrangler.toml b/test/npm/wrangler.toml new file mode 100644 index 0000000..4c09785 --- /dev/null +++ b/test/npm/wrangler.toml @@ -0,0 +1,4 @@ +name = "wrangler-action-test" +main = "./index.ts" +compatibility_date = "2023-07-07" +workers_dev = true diff --git a/test/pnpm/index.ts b/test/pnpm/index.ts new file mode 100644 index 0000000..a330557 --- /dev/null +++ b/test/pnpm/index.ts @@ -0,0 +1,26 @@ +type Env = { + SECRET1?: string; + SECRET2?: string; +}; + +export default { + fetch(request: Request, env: Env) { + const url = new URL(request.url); + + if (url.pathname === "/secret-health-check") { + const { SECRET1, SECRET2 } = env; + + if (SECRET1 !== "SECRET_1_VALUE" || SECRET2 !== "SECRET_2_VALUE") { + throw new Error("SECRET1 or SECRET2 is not defined"); + } + + return new Response("OK"); + } + + // @ts-expect-error + return Response.json({ + ...request, + headers: Object.fromEntries(request.headers), + }); + }, +}; diff --git a/test/pnpm/wrangler.toml b/test/pnpm/wrangler.toml new file mode 100644 index 0000000..4c09785 --- /dev/null +++ b/test/pnpm/wrangler.toml @@ -0,0 +1,4 @@ +name = "wrangler-action-test" +main = "./index.ts" +compatibility_date = "2023-07-07" +workers_dev = true diff --git a/test/yarn/index.ts b/test/yarn/index.ts new file mode 100644 index 0000000..a330557 --- /dev/null +++ b/test/yarn/index.ts @@ -0,0 +1,26 @@ +type Env = { + SECRET1?: string; + SECRET2?: string; +}; + +export default { + fetch(request: Request, env: Env) { + const url = new URL(request.url); + + if (url.pathname === "/secret-health-check") { + const { SECRET1, SECRET2 } = env; + + if (SECRET1 !== "SECRET_1_VALUE" || SECRET2 !== "SECRET_2_VALUE") { + throw new Error("SECRET1 or SECRET2 is not defined"); + } + + return new Response("OK"); + } + + // @ts-expect-error + return Response.json({ + ...request, + headers: Object.fromEntries(request.headers), + }); + }, +}; diff --git a/test/yarn/wrangler.toml b/test/yarn/wrangler.toml new file mode 100644 index 0000000..4c09785 --- /dev/null +++ b/test/yarn/wrangler.toml @@ -0,0 +1,4 @@ +name = "wrangler-action-test" +main = "./index.ts" +compatibility_date = "2023-07-07" +workers_dev = true