forked from amplify-education/serverless-domain-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add integration tests for migrating from v2 to v3
- Loading branch information
Sid Nutulapati
committed
Feb 14, 2019
1 parent
7dec136
commit 8db7489
Showing
4 changed files
with
95 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ const RANDOM_STRING = randomstring.generate({ | |
charset: "alphanumeric", | ||
capitalization: "lowercase", | ||
}); | ||
const TEMP_DIR = `~/tmp/domain-manager-test-${RANDOM_STRING}`; | ||
|
||
const testCases = [ | ||
{ | ||
|
@@ -277,4 +278,41 @@ describe("Integration Tests", function () { // eslint-disable-line func-names | |
await utilities.destroyResources(testName, testURL, RANDOM_STRING); | ||
}); | ||
}); | ||
|
||
describe("Migrating from 2.x.x to 3.x.x works", function () { // eslint-disable-line func-names | ||
this.timeout(15 * 60 * 1000); // 15 minutes in milliseconds | ||
const testName = "two-three-migration-default"; | ||
const tempDir = "~/tmp/domain-manager-test" | ||
const testURL = `${testName}-${RANDOM_STRING}.${TEST_DOMAIN}`; | ||
|
||
before(async () => { | ||
// Perform sequence of commands to replicate basepath mapping issue | ||
// Sleep for a min b/w commands in order to avoid rate limiting. | ||
await utilities.exec(`rm -rf ${tempDir}`); | ||
await utilities.exec(`mkdir -p ${tempDir} && cp -R test/integration-tests/${testName}/. ${tempDir}`); | ||
await utilities.exec(`cd ${tempDir}/ && npm install [email protected]`); | ||
}); | ||
|
||
it("Creates a basepath mapping", async () => { | ||
await utilities.exec(`cd ${tempDir} && sls create_domain --RANDOM_STRING ${RANDOM_STRING}`); | ||
await utilities.sleep(60); | ||
await utilities.exec(`cd ${tempDir} && sls deploy --RANDOM_STRING ${RANDOM_STRING}`); | ||
await utilities.sleep(60); | ||
// await utilities.exec(`npm link`) | ||
await utilities.exec(`cp -R . ${tempDir}/node_modules/serverless-domain-manager`); | ||
await utilities.exec(`cd ${tempDir} && sls deploy --RANDOM_STRING ${RANDOM_STRING}`); | ||
|
||
const basePath = await utilities.getBasePath(testURL); | ||
expect(basePath).to.equal("(none)"); | ||
}); | ||
|
||
after(async () => { | ||
// await utilities.exec(`npm unlink`); | ||
await utilities.exec(`cd ${tempDir} && sls remove --RANDOM_STRING ${RANDOM_STRING}`); | ||
await utilities.sleep(60); | ||
await utilities.exec(`cd ${tempDir} && sls delete_domain --RANDOM_STRING ${RANDOM_STRING}`); | ||
await utilities.sleep(60); | ||
await utilities.exec(`rm -rf ${tempDir}`); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
test/integration-tests/two-three-migration-default/handler.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
"use strict"; | ||
|
||
module.exports.helloWorld = (event, context, callback) => { | ||
const response = { | ||
statusCode: 200, | ||
headers: { | ||
"Access-Control-Allow-Origin": "*", // Required for CORS support to work | ||
}, | ||
body: JSON.stringify({ | ||
message: "Go Serverless v1.0! Your function executed successfully!", | ||
input: event, | ||
}), | ||
}; | ||
|
||
callback(null, response); | ||
}; |
19 changes: 19 additions & 0 deletions
19
test/integration-tests/two-three-migration-default/serverless.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Migrating from version 2 to version 3 | ||
service: two-three-migration-default | ||
provider: | ||
name: aws | ||
runtime: nodejs6.10 | ||
region: us-west-2 | ||
functions: | ||
helloWorld: | ||
handler: handler.helloWorld | ||
events: | ||
- http: | ||
path: hello-world | ||
method: get | ||
cors: true | ||
plugins: | ||
- serverless-domain-manager | ||
custom: | ||
customDomain: | ||
domainName: two-three-migration-default-${opt:RANDOM_STRING}.${env:TEST_DOMAIN} |