Skip to content

Instantly share code, notes, and snippets.

@draeder
Last active May 31, 2022 01:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save draeder/41d03377d8b9eb857234a7277091aa2f to your computer and use it in GitHub Desktop.
Save draeder/41d03377d8b9eb857234a7277091aa2f to your computer and use it in GitHub Desktop.
Gun Heroku one-click deploy testing
/**
* NOTE: Does not work with npm installed heroku-cli
* Uninstall with: npm uninstall heroku -g
* Install Heroku with: curl https://cli-assets.heroku.com/install.sh | sh
*/
const { exec } = require('node:child_process')
const expect = require('../expect')
describe('Heroku deploy', function(){
it('Returns an error if heroku CREATE fails', async function(){
this.timeout(15 * 1000)
let result = new Promise((resolve, reject) => {
exec('git init')
exec('heroku create test-gun-deploy', (error, stdout, stderr) => {
console.log(error || stdout || stderr)
if(error || stderr) {
//reject(error || stderr)
}
console.log(stdout)
if(stdout == 'https://test-gun-deploy.herokuapp.com/ | https://git.heroku.com/test-gun-deploy.git')
resolve(stdout)
})
})
expect(await result == 'https://test-gun-deploy.herokuapp.com/ | https://git.heroku.com/test-gun-deploy.git').to.be(true)
})
it('Returns an error if Heroku git remote is not set', async function(){
this.timeout(15 * 1000)
let result = new Promise((resolve, reject) => {
exec('heroku git:remote -a test-gun-deploy', (error, stdout, stderr) => {
//if(error || stderr) console.log(error || stderr)
console.log(stdout)
if(stdout === 'set git remote heroku to https://git.heroku.com/test-gun-deploy.git'){
resolve(stdout)
}
})
})
expect(await result === 'set git remote heroku to https://git.heroku.com/test-gun-deploy.git')
})
it('Returns an error if Heroku DEPLOY fails', async function(){
this.timeout(2 * 60 * 1000)
let result = new Promise((resolve, reject) => {
exec('git push heroku master', (error, stdout, stderr) => {
//if(error || stderr) reject(error || stderr)
console.log(stdout)
if(stdout === 'remote: Verifying deploy... done.'){
resolve(stdout)
}
})
})
expect(await result === 'remote: Verifying deploy... done.').to.be(true)
})
it('Returns an error if Heroku DELETE fails', async function(){
this.timeout(15 * 1000)
let result = new Promise((resolve, reject)=>{
exec('heroku apps:destroy test-gun-deploy --confirm=test-gun-deploy', (error, stdout, stderr) => {
//if(error || stderr) reject(error || stderr)
console.log(stdout)
if(stdout === 'Destroying ⬢ test-gun-deploy (including all add-ons)... done'){
resolve(stdout)
}
})
})
expect(await result === 'Destroying ⬢ test-gun-deploy (including all add-ons)... done').to.be(true)
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment