Skip to content

Commit

Permalink
chore: add smoke tests for pg-v5 and pipelines packages (#2355)
Browse files Browse the repository at this point in the history
* chore: add acceptance, integration, and smoke tests to ci

* chore: reorganize tests in the run package

* chore: reorg tests in ci and add smoke test run

* chore: add environment variables to integration, smoke, and acceptance tests

* chore: attempting another fix of the integration, smoke, and acceptance test jobs

* re-set CI tests

* chore: delete test workflow file

* chore: add smoke test for pg-v5 package

* chore: add smoke test for pipelines package

* chore: fix ci.yml after rebase

* chore: clean up smoke test variables

* fix: remove run package test after rebase

* chore: organize unit tests in pg-v5 package

* chore: organize unit tests in pipelines package
  • Loading branch information
k80bowman committed May 25, 2023
1 parent 23419d9 commit e8636c6
Show file tree
Hide file tree
Showing 68 changed files with 95 additions and 87 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Expand Up @@ -78,4 +78,3 @@ jobs:
- run: echo done
working-directory: /


25 changes: 17 additions & 8 deletions packages/cli/test/acceptance/smoke.acceptance.test.ts
Expand Up @@ -6,6 +6,8 @@ import * as qq from 'qqjs'

const globby = require('globby')

const app = 'heroku-cli-ci-smoke-test-app'
const appFlag = `-a=${app}`
const bin = path.join(__dirname, '../../bin/run')

function run(args = '') {
Expand All @@ -30,25 +32,32 @@ describe('@acceptance smoke tests', () => {
})

it('heroku apps:info', async () => {
const app = 'heroku-cli-ci-smoke-test-app'
const appFlag = `-a=${app}`
expect((await run(['info', appFlag].join(' '))).stdout).to.contain(app)
const {stdout} = await run(`info ${appFlag}`)
expect(stdout).to.contain(app)
})

it('heroku run', async () => {
const app = 'heroku-cli-ci-smoke-test-app'
const appFlag = `-a=${app}`
const {stdout} = await run(['run', '--exit-code', appFlag, 'echo', 'it works!'].join(' '))
expect(stdout).to.contain('it works!')
})

it('heroku access', async () => {
const app = 'heroku-cli-ci-smoke-test-app'
const appFlag = `-a=${app}`
const {stdout} = await run(['access', appFlag].join(' '))
const {stdout} = await run(`access ${appFlag}`)
expect(stdout).to.contain('heroku-cli@salesforce.com')
})

it('heroku pg:backups', async () => {
const {stdout} = await run(`pg:backups ${appFlag}`)
expect(stdout).to.match(/===.*Backups/)
expect(stdout).to.match(/===.*Restores/)
expect(stdout).to.match(/===.*Copies/)
})

it('heroku pipelines', async () => {
const {stdout} = await run('pipelines')
expect(stdout).to.match(/===.*My Pipelines/)
})

// TODO: turn this test back on once the issue with listing plugins is fixed
it.skip('asserts oclif plugins are in core', async () => {
const cmd = await run('plugins --core')
Expand Down
2 changes: 1 addition & 1 deletion packages/pg-v5/package.json
Expand Up @@ -63,7 +63,7 @@
"posttest": "yarn lint",
"prepack": "oclif manifest",
"release": "np",
"test": "cross-env TZ=utc nyc mocha",
"test": "cross-env TZ=utc nyc mocha --forbid-only \"test/**/*.unit.test.js\"",
"version": "oclif readme && git add README.md"
}
}
Expand Up @@ -4,7 +4,7 @@
const cli = require('heroku-cli-util')
const {expect} = require('chai')
const nock = require('nock')
const cmd = require('../../..').commands.find(c => c.topic === 'pg' && c.command === 'backups:cancel')
const cmd = require('../../../..').commands.find(c => c.topic === 'pg' && c.command === 'backups:cancel')

const shouldCancel = function (cmdRun) {
let pg
Expand Down
Expand Up @@ -7,7 +7,7 @@ const nock = require('nock')

const addon = {id: 1, name: 'postgres-1', plan: {name: 'heroku-postgresql:standard-0'}, app: {name: 'myapp'}}

const cmd = require('../../../commands/backups/capture')
const cmd = require('../../../../commands/backups/capture')

let captureText = () => {
if (process.stderr.isTTY) {
Expand Down
Expand Up @@ -4,7 +4,7 @@
const cli = require('heroku-cli-util')
const {expect} = require('chai')
const nock = require('nock')
const cmd = require('../../..').commands.find(c => c.topic === 'pg' && c.command === 'backups:delete')
const cmd = require('../../../..').commands.find(c => c.topic === 'pg' && c.command === 'backups:delete')

const shouldDelete = function (cmdRun) {
let pg
Expand Down
Expand Up @@ -4,7 +4,7 @@
const cli = require('heroku-cli-util')
const {expect} = require('chai')
const nock = require('nock')
const cmd = require('../../..').commands.find(c => c.topic === 'pg' && c.command === 'backups:download')
const cmd = require('../../../..').commands.find(c => c.topic === 'pg' && c.command === 'backups:download')
const fs = require('fs')

describe('pg:backups:download', () => {
Expand Down
Expand Up @@ -13,7 +13,7 @@ let cmdRun = function (name, cmd) {

args = Object.assign(args, {args: varArgs})

const backupsCmd = require('../../..').commands.find(c => c.topic === 'pg' && c.command === 'backups')
const backupsCmd = require('../../../..').commands.find(c => c.topic === 'pg' && c.command === 'backups')
return backupsCmd.run(args)
}
}
Expand Down
Expand Up @@ -4,7 +4,7 @@
const cli = require('heroku-cli-util')
const {expect} = require('chai')
const nock = require('nock')
const cmd = require('../../..').commands.find(c => c.topic === 'pg' && c.command === 'backups')
const cmd = require('../../../..').commands.find(c => c.topic === 'pg' && c.command === 'backups')

describe('pg:backups', () => {
let pg
Expand Down Expand Up @@ -190,7 +190,7 @@ c003 2016-10-08 00:42:54 +0000 Completed 2016-10-08 00:43:00 +0000 1.40KB RE
})

describe('pg:backups', () => {
const infoCmd = require('../../..').commands.find(c => c.topic === 'pg' && c.command === 'backups:info')
const infoCmd = require('../../../..').commands.find(c => c.topic === 'pg' && c.command === 'backups:info')

it('errors out when subcommand not found', () => {
return expect(require('./helpers.js').dup('foobar', infoCmd)({})).to.be.rejectedWith('Unknown pg:backups command: foobar')
Expand Down
Expand Up @@ -4,7 +4,7 @@
const cli = require('heroku-cli-util')
const {expect} = require('chai')
const nock = require('nock')
const cmd = require('../../..').commands.find(c => c.topic === 'pg' && c.command === 'backups:info')
const cmd = require('../../../..').commands.find(c => c.topic === 'pg' && c.command === 'backups:info')

const shouldInfo = function (cmdRun) {
let pg
Expand Down
Expand Up @@ -7,7 +7,7 @@ const nock = require('nock')

const addon = {id: 1, name: 'postgres-1', plan: {name: 'heroku-postgresql:standard-0'}, app: {name: 'myapp'}}

const cmd = require('../../../commands/backups/restore')
const cmd = require('../../../../commands/backups/restore')

let restoringText = () => {
return process.stderr.isTTY ? 'Restoring... pending\nRestoring... done\n' : 'Restoring... done\n'
Expand Down
Expand Up @@ -4,7 +4,7 @@
const cli = require('heroku-cli-util')
const {expect} = require('chai')
const nock = require('nock')
const cmd = require('../../..').commands.find(c => c.topic === 'pg' && c.command === 'backups:schedule')
const cmd = require('../../../..').commands.find(c => c.topic === 'pg' && c.command === 'backups:schedule')

const shouldSchedule = function (cmdRun) {
let pg
Expand Down
Expand Up @@ -4,7 +4,7 @@
const cli = require('heroku-cli-util')
const {expect} = require('chai')
const nock = require('nock')
const cmd = require('../../..').commands.find(c => c.topic === 'pg' && c.command === 'backups:schedules')
const cmd = require('../../../..').commands.find(c => c.topic === 'pg' && c.command === 'backups:schedules')

const shouldSchedules = function (cmdRun) {
let api
Expand Down
Expand Up @@ -4,7 +4,7 @@
const cli = require('heroku-cli-util')
const {expect} = require('chai')
const nock = require('nock')
const cmd = require('../../..').commands.find(c => c.topic === 'pg' && c.command === 'backups:unschedule')
const cmd = require('../../../..').commands.find(c => c.topic === 'pg' && c.command === 'backups:unschedule')

const addon = {
id: 1,
Expand Down
Expand Up @@ -4,7 +4,7 @@
const cli = require('heroku-cli-util')
const {expect} = require('chai')
const nock = require('nock')
const cmd = require('../../..').commands.find(c => c.topic === 'pg' && c.command === 'backups:url')
const cmd = require('../../../..').commands.find(c => c.topic === 'pg' && c.command === 'backups:url')

const shouldUrl = function (cmdRun) {
let pg
Expand Down
Expand Up @@ -27,7 +27,7 @@ const fetcher = () => {
}
}

const cmd = proxyquire('../../commands/connection_pooling', {
const cmd = proxyquire('../../../commands/connection_pooling', {
'../lib/fetcher': fetcher,
})

Expand Down
Expand Up @@ -4,9 +4,9 @@
const cli = require('heroku-cli-util')
const {expect} = require('chai')
const nock = require('nock')
const unwrap = require('../unwrap')
const unwrap = require('../../unwrap')

const cmd = require('../..').commands.find(c => c.topic === 'pg' && c.command === 'copy')
const cmd = require('../../..').commands.find(c => c.topic === 'pg' && c.command === 'copy')

const addon = {
id: 1,
Expand Down
Expand Up @@ -27,7 +27,7 @@ const fetcher = () => {
}
}

const cmd = proxyquire('../../commands/credentials', {
const cmd = proxyquire('../../../commands/credentials', {
'../lib/fetcher': fetcher,
})

Expand Down
Expand Up @@ -26,7 +26,7 @@ const fetcher = () => {
}
}

const cmd = proxyquire('../../../commands/credentials/create', {
const cmd = proxyquire('../../../../commands/credentials/create', {
'../../lib/fetcher': fetcher,
})

Expand Down Expand Up @@ -68,7 +68,7 @@ Please define the new grants for the credential within Postgres: heroku pg:psql
}
}

const cmd = proxyquire('../../../commands/credentials/create', {
const cmd = proxyquire('../../../../commands/credentials/create', {
'../../lib/fetcher': fetcher,
})

Expand Down
Expand Up @@ -26,7 +26,7 @@ const fetcher = () => {
}
}

const cmd = proxyquire('../../../commands/credentials/destroy', {
const cmd = proxyquire('../../../../commands/credentials/destroy', {
'../../lib/fetcher': fetcher,
})

Expand Down Expand Up @@ -75,7 +75,7 @@ Database objects owned by credname will be assigned to the default credential.
}
}

const cmd = proxyquire('../../../commands/credentials/destroy', {
const cmd = proxyquire('../../../../commands/credentials/destroy', {
'../../lib/fetcher': fetcher,
})

Expand Down
Expand Up @@ -26,7 +26,7 @@ const fetcher = () => {
}
}

const cmd = proxyquire('../../../commands/credentials/repair_default', {
const cmd = proxyquire('../../../../commands/credentials/repair_default', {
'../../lib/fetcher': fetcher,
})

Expand Down Expand Up @@ -65,7 +65,7 @@ describe('pg:credentials:repair-default', () => {
}
}

const cmd = proxyquire('../../../commands/credentials/repair_default', {
const cmd = proxyquire('../../../../commands/credentials/repair_default', {
'../../lib/fetcher': fetcher,
})

Expand Down
Expand Up @@ -42,7 +42,7 @@ const fetcher = () => {
}
}

const cmd = proxyquire('../../../commands/credentials/rotate', {
const cmd = proxyquire('../../../../commands/credentials/rotate', {
'../../lib/fetcher': fetcher,
})

Expand Down Expand Up @@ -118,7 +118,7 @@ describe('pg:credentials:rotate', () => {
}
}

const cmd = proxyquire('../../../commands/credentials/rotate', {
const cmd = proxyquire('../../../../commands/credentials/rotate', {
'../../lib/fetcher': fetcher,
})

Expand All @@ -139,7 +139,7 @@ describe('pg:credentials:rotate', () => {
}
}

const cmd = proxyquire('../../../commands/credentials/rotate', {
const cmd = proxyquire('../../../../commands/credentials/rotate', {
'../../lib/fetcher': fetcher,
})

Expand All @@ -162,7 +162,7 @@ describe('pg:credentials:rotate', () => {
}
}

const cmd = proxyquire('../../../commands/credentials/rotate', {
const cmd = proxyquire('../../../../commands/credentials/rotate', {
'../../lib/fetcher': fetcher,
})

Expand Down
Expand Up @@ -26,7 +26,7 @@ const fetcher = () => {
}
}

const cmd = proxyquire('../../../commands/credentials/url', {
const cmd = proxyquire('../../../../commands/credentials/url', {
'../../lib/fetcher': fetcher,
})

Expand Down Expand Up @@ -91,7 +91,7 @@ Connection URL:
}
}

const cmd = proxyquire('../../../commands/credentials/url', {
const cmd = proxyquire('../../../../commands/credentials/url', {
'../../lib/fetcher': fetcher,
})

Expand All @@ -112,7 +112,7 @@ Connection URL:
}
}

const cmd = proxyquire('../../../commands/credentials/url', {
const cmd = proxyquire('../../../../commands/credentials/url', {
'../../lib/fetcher': fetcher,
})

Expand Down
Expand Up @@ -32,7 +32,7 @@ describe('pg:diagnose', () => {
}
}

const cmd = proxyquire('../../commands/diagnose', {
const cmd = proxyquire('../../../commands/diagnose', {
'../lib/fetcher': fetcher,
})

Expand Down
Expand Up @@ -5,7 +5,7 @@ const cli = require('heroku-cli-util')
const {expect} = require('chai')
const nock = require('nock')
const proxyquire = require('proxyquire')
const unwrap = require('../unwrap')
const unwrap = require('../../unwrap')

let all = []
let addon
Expand All @@ -16,7 +16,7 @@ const fetcher = () => {
}
}

const cmd = proxyquire('../../commands/info', {
const cmd = proxyquire('../../../commands/info', {
'../lib/fetcher': fetcher,
})[0]

Expand Down
Expand Up @@ -20,7 +20,7 @@ const psql = {
},
}

const cmd = proxyquire('../../commands/kill', {
const cmd = proxyquire('../../../commands/kill', {
'../lib/fetcher': fetcher,
'../lib/psql': psql,
})
Expand Down
Expand Up @@ -13,7 +13,7 @@ const fetcher = () => {
}
}

const cmd = proxyquire('../../commands/killall', {
const cmd = proxyquire('../../../commands/killall', {
'../lib/fetcher': fetcher,
})

Expand Down
Expand Up @@ -12,7 +12,7 @@ const addon = {
plan: {name: 'heroku-postgresql:standard-0'},
}

const cmd = proxyquire('../../../commands/links/create', {
const cmd = proxyquire('../../../../commands/links/create', {
'@heroku-cli/plugin-addons': {
resolve: {addon: () => addon},
},
Expand Down
Expand Up @@ -12,7 +12,7 @@ const addon = {
plan: {name: 'heroku-postgresql:standard-0'},
}

const cmd = proxyquire('../../../commands/links/destroy', {
const cmd = proxyquire('../../../../commands/links/destroy', {
'@heroku-cli/plugin-addons': {
resolve: {addon: () => addon},
},
Expand Down
Expand Up @@ -18,7 +18,7 @@ const fetcher = () => {
}
}

const cmd = proxyquire('../../../commands/links', {
const cmd = proxyquire('../../../../commands/links', {
'../../lib/fetcher': fetcher,
})

Expand Down

0 comments on commit e8636c6

Please sign in to comment.