3
3
4
4
let cmd = commands . find ( ( c ) => c . topic === 'addons' && c . command === 'upgrade' )
5
5
let expect = require ( 'unexpected' )
6
+ let cache = require ( '../../../lib/resolve' ) . addon . cache
7
+
6
8
describe ( 'addons:upgrade' , ( ) => {
7
- beforeEach ( ( ) => cli . mockConsole ( ) )
9
+ beforeEach ( ( ) => {
10
+ cli . mockConsole ( )
11
+ cache . clear ( )
12
+ } )
13
+
8
14
afterEach ( ( ) => nock . cleanAll ( ) )
9
15
10
16
it ( 'upgrades an add-on' , ( ) => {
@@ -20,6 +26,19 @@ describe('addons:upgrade', () => {
20
26
. then ( ( ) => api . done ( ) )
21
27
} )
22
28
29
+ it ( 'upgrades to a contract add-on' , ( ) => {
30
+ let addon = { name : 'connect-swiftly-123' , addon_service : { name : 'heroku-connect' } , app : { name : 'myapp' } , plan : { name : 'free' } }
31
+
32
+ let api = nock ( 'https://api.heroku.com:443' )
33
+ . post ( '/actions/addons/resolve' , { 'app' : 'myapp' , 'addon' : 'heroku-connect' } ) . reply ( 200 , [ addon ] )
34
+ . patch ( '/apps/myapp/addons/connect-swiftly-123' , { plan : { name : 'heroku-connect:contract' } } )
35
+ . reply ( 200 , { plan : { price : { cents : 0 , contract : true } } , provision_message : 'provision msg' } )
36
+ return cmd . run ( { app : 'myapp' , args : { addon : 'heroku-connect' , plan : 'heroku-connect:contract' } } )
37
+ . then ( ( ) => expect ( cli . stdout , 'to equal' , 'provision msg\n' ) )
38
+ . then ( ( ) => expect ( cli . stderr , 'to equal' , 'Changing connect-swiftly-123 on myapp from free to heroku-connect:contract... done, contract\n' ) )
39
+ . then ( ( ) => api . done ( ) )
40
+ } )
41
+
23
42
it ( 'upgrades an add-on with only one argument' , ( ) => {
24
43
let addon = { name : 'postgresql-swiftly-123' , addon_service : { name : 'heroku-postgresql' } , app : { name : 'myapp' } , plan : { name : 'premium-0' } }
25
44
0 commit comments