Skip to content
Myr

fix(lambda-edge): update schema and refactor (#1230)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* remove array check * update if * fix test * fix origin infomation

authored by watany · committed by GitHub · parent 096e3b7 · Browse files · 2 files+30 added−10 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+30 added−10 removed

  • tests:+25 added−5 removed
  • other:+5 added−5 removed

2 files+30 added−10 removed

modified:runtime_tests/lambda-edge/index.test.ts+25 added-5 removed
69 unmodified lines
70 }71 const response = await handler(event)72 expect(response.status).toBe('200')73 expect(response.body).toBe('Hello Lambda!')74 if(response.headers && response.headers['content-type']){74 expect(response.headers['content-type'][0].value).toMatch(/^text\/plain/)75 expect(response.headers['content-type'][0].value).toMatch(/^text\/plain/)76 } else {77 throw new Error("'content-type' header is missing in the response");78 }79 })8081 it('Should handle a GET request and return a 200 response (Lambda@Edge origin request)', async () => {82 const event = {
62 unmodified lines
145 }146 const response = await handler(event)147 expect(response.status).toBe('200')148 expect(response.body).toBe('Hello Lambda!')149 if(response.headers && response.headers['content-type']){145 expect(response.headers['content-type'][0].value).toMatch(/^text\/plain/)150 expect(response.headers['content-type'][0].value).toMatch(/^text\/plain/)151 } else {152 throw new Error("'content-type' header is missing in the response");153 }154 })155156 it('Should handle a GET request and return a 200 response (Lambda@Edge viewer response)', async () => {157 const event = {
110 unmodified lines
268 }269 const response = await handler(event)270 expect(response.status).toBe('200')271 expect(response.body).toBe('Hello Lambda!')272 if(response.headers && response.headers['content-type']){264 expect(response.headers['content-type'][0].value).toMatch(/^text\/plain/)273 expect(response.headers['content-type'][0].value).toMatch(/^text\/plain/)274 } else {275 throw new Error("'content-type' header is missing in the response");276 }277 })278279 it('Should handle a GET request and return a 200 response (Lambda@Edge origin response)', async () => {280 const event = {
128 unmodified lines
409 }410 const response = await handler(event)411 expect(response.status).toBe('200')412 expect(response.body).toBe('Hello Lambda!')413 if(response.headers && response.headers['content-type']){401 expect(response.headers['content-type'][0].value).toMatch(/^text\/plain/)414 expect(response.headers['content-type'][0].value).toMatch(/^text\/plain/)415 } else {416 throw new Error("'content-type' header is missing in the response");417 }418 })419420 it('Should handle a GET request and return a 200 response with binary', async () => {421 const event = {
28 unmodified lines
450 const response = await handler(event)451452 expect(response.status).toBe('200')453 expect(response.body).toBe('RmFrZSBJbWFnZQ==') // base64 encoded fake image454 if(response.headers && response.headers['content-type']){438 expect(response.headers['content-type'][0].value).toMatch(/^image\/png/)455 expect(response.headers['content-type'][0].value).toMatch(/^image\/png/)456 } else {457 throw new Error("'content-type' header is missing in the response");458 }459 })460461 it('Should handle a GET request and return a 404 response', async () => {462 const event = {
166 unmodified lines
modified:src/adapter/lambda-edge/handler.ts+5 added-5 removed