-
Notifications
You must be signed in to change notification settings - Fork 234
Expand file tree
/
Copy pathwindow.js
More file actions
52 lines (44 loc) · 1.33 KB
/
window.js
File metadata and controls
52 lines (44 loc) · 1.33 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
'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/window', {
'../../lib/fetcher': fetcher,
})
describe('pg:maintenance', () => {
let api
let pg
let displayed = ` ▸ You can also change the maintenance window with
▸ data:maintenances:window:update.
▸ 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('sets maintenance window', () => {
pg.put('/client/v11/databases/1/maintenance_window', {description: 'Sunday 06:30'}).reply(200)
return cmd.run({app: 'myapp', args: {window: 'Sunday 06:30'}})
.then(() => expect(cli.stdout).to.equal(''))
.then(() => expect(cli.stderr).to.equal(displayed + 'Setting maintenance window for postgres-1 to Sunday 06:30... done\n'))
})
})