Skip to content

Commit

Permalink
Add test for pre-installed wrangler
Browse files Browse the repository at this point in the history
  • Loading branch information
AdiRishi committed Feb 9, 2024
1 parent c97aabc commit 3fa14d7
Show file tree
Hide file tree
Showing 4 changed files with 1,319 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,16 @@ jobs:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: deploy --dry-run

- name: Change directory to pre-installed-wrangler and install dependencies
run: |
cd ./test/pre-installed-wrangler
npm install
- name: Support pre-installed wrangler
uses: ./
with:
workingDirectory: "./test/pre-installed-wrangler"
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: deploy --dry-run
25 changes: 25 additions & 0 deletions test/pre-installed-wrangler/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
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");
}

return Response.json({
...request,
headers: Object.fromEntries(request.headers),
});
},
};
Loading

0 comments on commit 3fa14d7

Please sign in to comment.