Skip to content

Commit a22643d

Browse files
activation of acceptance and integration tests (#3520)
* activation of acceptance and integration tests * resolving linting errors * resolving linting errors * resolving merge conflicts * accepting admin or collaborator for when testing locally or in ci * updating the change to use npx instead of yarn
1 parent 2af5d0a commit a22643d

14 files changed

+426
-342
lines changed

bin/bats-test-runner.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env node
22

3-
const os = require('os')
4-
const {spawn} = require('child_process')
3+
import os from 'os'
4+
import { spawn } from 'child_process'
55

66
if (os.platform() === 'win32' || os.platform() === 'windows') console.log('skipping on windows')
7-
else spawn('yarn bats test/acceptance/*.bats', {stdio: 'inherit', shell: true})
7+
else spawn('npx bats test/acceptance/*.bats', {stdio: 'inherit', shell: true})

cspell-dictionary.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ aname
1212
APAC
1313
apikey
1414
appname
15+
applink
1516
apresharedkey
1617
armel
1718
armhf

test/acceptance/commands-output.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export default `Command Summary
1+
export default ` Id Summary
22
────────────────────────────────────────────── ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
33
2fa check 2fa status
44
2fa:disable disables 2fa on account
@@ -87,14 +87,13 @@ clients:destroy delete client by ID
8787
clients:info show details of an oauth client
8888
clients:rotate rotate OAuth client secret
8989
clients:update update OAuth client
90-
commands list all the commands
90+
commands list all heroku commands.
9191
config display the config vars for an app
9292
config:edit interactively edit config vars
9393
config:get display a single config value for an app
9494
config:remove unset one or more config vars
9595
config:set set one or more config vars
9696
config:unset unset one or more config vars
97-
container Use containers to build and deploy Heroku apps
9897
container:login log in to Heroku Container Registry
9998
container:logout log out from Heroku Container Registry
10099
container:pull pulls an image from an app's process type
@@ -224,9 +223,9 @@ pipelines:setup bootstrap a new pipeline with com
224223
pipelines:transfer transfer ownership of a pipeline
225224
pipelines:update update the app's stage in a pipeline
226225
plugins List installed plugins.
227-
plugins:add Installs a plugin into the CLI.
226+
plugins:add Installs a plugin into heroku.
228227
plugins:inspect Displays installation properties of a plugin.
229-
plugins:install Installs a plugin into the CLI.
228+
plugins:install Installs a plugin into heroku.
230229
plugins:link Links a plugin into the CLI for development.
231230
plugins:remove Removes a plugin from the CLI.
232231
plugins:uninstall Removes a plugin from the CLI.
@@ -235,14 +234,10 @@ plugins:update Update installed plugins.
235234
ps list dynos for an app
236235
ps:autoscale:disable disable web dyno autoscaling
237236
ps:autoscale:enable enable web dyno autoscaling
238-
ps:copy Copy a file from a dyno to the local filesystem
239-
ps:exec Create an SSH session to a dyno
240-
ps:forward Forward traffic on a local port to a dyno
241237
ps:kill stop an app dyno or process type
242238
ps:resize manage dyno sizes
243239
ps:restart restart an app dyno or process type
244240
ps:scale scale dyno quantity up or down
245-
ps:socks Launch a SOCKS proxy into a dyno
246241
ps:stop stop an app dyno or process type
247242
ps:type manage dyno sizes
248243
ps:wait wait for all dynos to be running latest version after a release
@@ -252,7 +247,6 @@ redis:cli opens a redis prompt
252247
redis:credentials display credentials information
253248
redis:info gets information about redis
254249
redis:keyspace-notifications set the keyspace notifications configuration
255-
redis:maintenance manage maintenance windows
256250
redis:maxmemory set the key eviction policy when instances reach their storage limit
257251
redis:promote sets DATABASE as your REDIS_URL
258252
redis:stats-reset reset all stats covered by RESETSTAT (https://redis.io/commands/config-resetstat)
Lines changed: 57 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,74 @@
11
import execa from 'execa'
2-
import * as fs from 'fs-extra'
2+
import fs from 'fs-extra'
3+
import {fileURLToPath} from 'node:url'
34
import * as path from 'path'
45

5-
const plugins = ['heroku-ps-exec']
6+
const __filename = fileURLToPath(import.meta.url)
7+
const __dirname = path.dirname(__filename)
8+
const plugins = ['@heroku-cli/plugin-applink']
69

710
const skipOnWindows = process.platform === 'win32' ? it.skip : it
811

9-
describe.skip('plugins', function () {
12+
function resolvePluginPath(plugin: string): null | string {
13+
const candidates = [
14+
path.resolve(__dirname, '../../node_modules', plugin, 'package.json'),
15+
path.resolve(__dirname, '../../../node_modules', plugin, 'package.json'),
16+
]
17+
18+
for (const p of candidates) {
19+
if (fs.existsSync(p)) return path.dirname(p)
20+
}
21+
22+
return null
23+
}
24+
25+
function safeCloneDirName(plugin: string): string {
26+
return plugin.replace('@heroku-cli/', '')
27+
}
28+
29+
describe('plugins', function () {
1030
plugins.forEach(plugin => {
31+
const pluginRoot = resolvePluginPath(plugin)
32+
if (!pluginRoot) {
33+
it.skip(plugin, async function () {})
34+
return
35+
}
36+
1137
skipOnWindows(plugin, async () => {
12-
const cwd = path.join(__dirname, '../../tmp/plugin', plugin)
38+
const cwd = path.resolve(__dirname, '../../tmp/plugin', safeCloneDirName(plugin))
1339
await fs.remove(cwd)
14-
const pkg = await fs.readJSON(path.join(__dirname, '../../node_modules', plugin, 'package.json'))
15-
if (!pkg.repository) {
40+
const pkg = await fs.readJSON(path.join(pluginRoot, 'package.json'))
41+
const repo = pkg.repository
42+
43+
if (!repo) {
1644
throw new Error('No repository found')
1745
}
1846

19-
await execa('git', ['clone', pkg.repository.url.split('+')[1], cwd])
47+
const repoUrl = typeof repo === 'string' ? repo : repo.url
48+
49+
if (!repoUrl) {
50+
throw new Error('No repository URL found in package.json')
51+
}
52+
53+
let cloneUrl: string
54+
55+
if (repoUrl.includes('+')) {
56+
cloneUrl = repoUrl.split('+')[1]
57+
} else if (repoUrl.startsWith('github:')) {
58+
cloneUrl = `https://github.com/${repoUrl.slice(7)}.git`
59+
} else if (repoUrl.startsWith('http://') || repoUrl.startsWith('https://')) {
60+
cloneUrl = repoUrl
61+
} else if (/^[^/]+\/[^/]+$/.test(repoUrl)) {
62+
cloneUrl = `https://github.com/${repoUrl}.git`
63+
} else {
64+
cloneUrl = repoUrl
65+
}
66+
67+
await execa('git', ['clone', cloneUrl, cwd])
2068
const opts = {cwd, stdio: [0, 1, 2]}
2169
await execa('git', ['checkout', `v${pkg.version}`], opts)
22-
await execa('yarn', [], opts)
23-
await execa('yarn', ['test'], opts)
70+
await execa('npm', [], opts)
71+
await execa('npm', ['test'], opts)
2472
})
2573
})
2674
})

0 commit comments

Comments
 (0)