Skip to content

Commit

Permalink
Get e2e passing
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchmac committed Feb 16, 2024
1 parent afe750a commit ae43be1
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
working-directory: ./tests/e2e

- run: >
curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{"path":"/index.php"}'
curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{"path":"/index.php"}' | grep -q '{"statusCode":200,"headers"'
- run: >
curl -s -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{"path":"/index.php", "postRequestPlugin": "1"}' | grep -q '{"statusCode":201,"body":"Foo"}'
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async function handler(data) {
const { event, docRoot } = data;

const preRequestResponse = await plugins.executePreRequest(event);
if (preRequestResponse !== null) {
if (preRequestResponse != null) {
return preRequestResponse;
}

Expand Down
8 changes: 4 additions & 4 deletions tests/e2e/local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

docker run -p 9000:8080 -d --name serverlesswp-local docker-lambda-serverlesswp

curl -s -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{"path":"/index.php"}' | grep -q '{"statusCode":200,"headers"'
curl -s -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{"path":"/index.php"}' | grep -q '{"statusCode":200,"headers"' || echo 'fail 1'

curl -s -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{"path":"/index.php", "postRequestPlugin": "1"}' | grep -q '{"statusCode":201,"body":"Foo"}'
curl -s -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{"path":"/index.php", "postRequestPlugin": "1"}' | grep -q '{"statusCode":201,"body":"Foo"}' || echo 'fail 2'

curl -s -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{"path":"/index.php", "preRequestPlugin": "1"}' | grep -q '{"statusCode":200,"body":"Foo"}'
curl -s -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{"path":"/index.php", "preRequestPlugin": "1"}' | grep -q '{"statusCode":200,"body":"Foo"}' || echo 'fail 3'

curl -s -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{"path":"/static.css"}' | grep -q 'background-color: blue'
curl -s -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{"path":"/static.css"}' | grep -q 'background-color: blue' || echo 'fail 4'

docker stop serverlesswp-local
docker rm serverlesswp-local
4 changes: 2 additions & 2 deletions tests/e2e/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ serverlesswp.registerPlugin({
name: 'postRequest',
postRequest: async function(event, pluginResponse) {
// Bypass this plugin conditionally
if (event.postRequestPlugin) {
if (event.hasOwnProperty("postRequestPlugin")) {
return {
statusCode: pluginResponse.statusCode + 1,
body: 'Foo'
Expand All @@ -18,7 +18,7 @@ serverlesswp.registerPlugin({
name: 'preRequest',
preRequest: async function(event) {
// Bypass this plugin conditionally
if (event.preRequestPlugin) {
if (event.hasOwnProperty("preRequestPlugin")) {
return {
statusCode: 200,
body: 'Foo'
Expand Down

0 comments on commit ae43be1

Please sign in to comment.