-
Notifications
You must be signed in to change notification settings - Fork 367
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 addon creation flow
- Loading branch information
1 parent
259dfbf
commit 8c497f7
Showing
7 changed files
with
129 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
const path = require('path') | ||
const test = require('ava') | ||
const cliPath = require('./utils/cliPath') | ||
const exec = require('./utils/exec') | ||
const sitePath = path.join(__dirname, 'dummy-site') | ||
|
||
const execOptions = { | ||
stdio: [0, 1, 2], | ||
cwd: sitePath, | ||
env: { | ||
...process.env, | ||
NETLIFY_AUTH_TOKEN: process.env.NETLIFY_AUTH_TOKEN, | ||
NETLIFY_SITE_ID: process.env.NETLIFY_SITE_ID | ||
}, | ||
} | ||
|
||
async function deleteAddon(name) { | ||
const cliResponse = await exec(`${cliPath} addons:delete ${name}`, execOptions) | ||
return cliResponse | ||
} | ||
|
||
// test.before(t => { | ||
// // create site | ||
// }) | ||
|
||
test.serial('netlify addon:list', async (t) => { | ||
const regex = /^No addons currently installed/ | ||
const cliResponse = await exec(`${cliPath} addons:list`, execOptions) | ||
t.is(regex.test(cliResponse.stdout), true) | ||
}) | ||
|
||
test.serial('netlify addon:list --json', async (t) => { | ||
const cliResponse = await exec(`${cliPath} addons:list --json`, execOptions) | ||
const json = JSON.parse(cliResponse.stdout) | ||
t.is(Array.isArray(json), true) | ||
t.is(json.length, 0) | ||
}) | ||
|
||
test.serial('netlify addon:create demo', async (t) => { | ||
const regex = /Add-on "demo" created/ | ||
const cliResponse = await exec(`${cliPath} addons:create demo --TWILIO_ACCOUNT_SID lol`, execOptions) | ||
t.is(regex.test(cliResponse.stdout), true) | ||
}) | ||
|
||
test.serial('After creation netlify addon:list --json', async (t) => { | ||
const cliResponse = await exec(`${cliPath} addons:list --json`, execOptions) | ||
const json = JSON.parse(cliResponse.stdout) | ||
t.is(Array.isArray(json), true) | ||
t.is(json.length, 1) | ||
t.is(json[0].service_slug, 'demo') | ||
}) | ||
|
||
test.serial('netlify addon:delete demo', async (t) => { | ||
const regex = /Add-on "demo" deleted/ | ||
const cliResponse = await deleteAddon('demo') | ||
t.is(regex.test(cliResponse.stdout), true) | ||
}) | ||
|
||
test.after('cleanup', async t => { | ||
console.log('Performing cleanup') | ||
// Run cleanup | ||
await deleteAddon('demo') | ||
}) |
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 @@ | ||
<!doctype html> | ||
<html class="no-js" lang=""> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<title></title> | ||
<meta name="description" content=""> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
</head> | ||
|
||
<body> | ||
<h1>⊂◉‿◉つ</h1> | ||
</body> | ||
|
||
</html> |
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 @@ | ||
<!doctype html> | ||
<html class="no-js" lang=""> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<title></title> | ||
<meta name="description" content=""> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
</head> | ||
|
||
<body> | ||
<h1>⊂◉‿◉つ</h1> | ||
</body> | ||
|
||
</html> |
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,3 @@ | ||
[build] | ||
command = "npm run build" | ||
publish = "build" |
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,13 @@ | ||
{ | ||
"name": "dummy-site", | ||
"version": "1.0.0", | ||
"private": true, | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"prebuild": "rm -rf build && mkdir build", | ||
"build": "cp index.html build" | ||
}, | ||
"author": "David Wells", | ||
"license": "MIT" | ||
} |
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,5 @@ | ||
const path = require('path') | ||
|
||
const cliPath = path.join(__dirname, '..', '..', '..', 'bin/run') | ||
|
||
module.exports = cliPath |
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,13 @@ | ||
const { exec } = require('child_process') | ||
|
||
module.exports = (cmd, opts) => | ||
new Promise((resolve, reject) => { | ||
const dirOutput = (opts && opts.cwd) ? `\nDIR: ${opts.cwd}` : '' | ||
console.log(`Running command...\nCMD: ${cmd}${dirOutput}`) | ||
exec(cmd, opts, (err, stdout, stderr) => { | ||
if (err) { | ||
return reject(err) | ||
} | ||
return resolve({ stdout, stderr }) | ||
}) | ||
}) |