-
Notifications
You must be signed in to change notification settings - Fork 234
Expand file tree
/
Copy pathrun.js
More file actions
53 lines (44 loc) · 1.3 KB
/
run.js
File metadata and controls
53 lines (44 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
'use strict'
/* global beforeEach afterEach */
const cli = require('heroku-cli-util')
const {expect} = require('chai')
const nock = require('nock')
const proxyquire = require('proxyquire')
const db = {
id: 1,
name: 'postgres-1',
plan: {name: 'heroku-postgresql:standard-0'},
}
const fetcher = () => {
return {
addon: () => db,
}
}
const cmd = proxyquire('../../../commands/maintenance/run', {
'../../lib/fetcher': fetcher,
})
describe('pg:maintenance', () => {
let api
let pg
let displayed = ` ▸ You can also start a maintenance with data:maintenances:run.
▸ Follow https://devcenter.heroku.com/articles/data-maintenance-cli-commands
▸ to install the Data Maintenance CLI plugin.
`
beforeEach(() => {
api = nock('https://api.heroku.com')
pg = nock('https://postgres-api.heroku.com')
cli.mockConsole()
})
afterEach(() => {
nock.cleanAll()
api.done()
pg.done()
})
it('runs maintenance', () => {
api.get('/apps/myapp').reply(200, {maintenance: true})
pg.post('/client/v11/databases/1/maintenance').reply(200, {message: 'foo'})
return cmd.run({app: 'myapp', args: {}, flags: {}})
.then(() => expect(cli.stderr).to.equal(displayed + 'Starting maintenance for postgres-1... foo\n'))
.then(() => expect(cli.stdout).to.equal(''))
})
})