Add test for pre-installed wrangler

This commit is contained in:
Adishwar Rishi 2024-02-09 22:34:42 +11:00 committed by Peter Bacon Darwin
parent f78ca6a656
commit b78dcf8ecc
4 changed files with 1319 additions and 0 deletions

View file

@ -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

View file

@ -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),
});
},
};

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,8 @@
{
"name": "wrangler-action-pre-installed-wrangler-test",
"license": "MIT",
"private": true,
"devDependencies": {
"wrangler": "^3.28.0"
}
}