Skip to content

Commit

Permalink
Integration test for passing a request body to kv-store put (#766)
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed May 7, 2024
1 parent 56f8dde commit 3042796
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion integration-tests/js-compute/fixtures/app/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ async function setupSecretStore() {
return []
}
}())
const STORE_ID = stores.find(({ name }) => name === 'example-test-secret-store')?.id
const STORE_ID = stores?.find(({ name }) => name === 'example-test-secret-store')?.id
if (!STORE_ID) {
process.env.STORE_ID = JSON.parse(await zx`fastly secret-store create --quiet --name=example-test-secret-store --json --token $FASTLY_API_TOKEN`).id
} else {
Expand Down
9 changes: 9 additions & 0 deletions integration-tests/js-compute/fixtures/app/src/kv-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,15 @@ import { routes, isRunningLocally } from "./routes.js";
if (error) { return error }
return pass()
});
routes.set("/kv-store/put/request-body", async ({ request }) => {
const store = createValidStore()
let result = store.put('readablestream-req', request.body)
let error = assert(result instanceof Promise, true, `store.put('readablestream-req', request.body) instanceof Promise`)
if (error) { return error }
error = assert(await result, undefined, `await store.put('readablestream-req', request.body)`)
if (error) { return error }
return pass()
});
routes.set("/kv-store/put/value-parameter-readablestream-over-30mb", async () => {
// TODO: remove this when streams are supported
let error = await assertRejects(async () => {
Expand Down
12 changes: 12 additions & 0 deletions integration-tests/js-compute/fixtures/app/tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -3539,6 +3539,18 @@
"status": 200
}
},
"POST /kv-store/put/request-body": {
"environments": ["compute"],
"downstream_request": {
"method": "POST",
"pathname": "/kv-store/put/request-body",
"headers": ["Content-Type", "application/json"],
"body": "hello world!"
},
"downstream_response": {
"status": 200
}
},
"GET /kv-store/delete/called-as-constructor": {
"environments": ["compute", "viceroy"],
"downstream_request": {
Expand Down

0 comments on commit 3042796

Please sign in to comment.