Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add smoke tests for pg-v5 and pipelines packages #2355

Merged
merged 14 commits into from
May 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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}`
Comment on lines +9 to +10
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you.

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
Original file line number Diff line number Diff line change
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"
}
}
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const fetcher = () => {
}
}

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

Expand Down
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('pg:diagnose', () => {
}
}

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

Expand Down
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const fetcher = () => {
}
}

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

Expand Down
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const fetcher = () => {
}
}

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

Expand Down