@@ -11,7 +11,9 @@ module.exports = () => {
11
11
// test update
12
12
tap . test ( 'Should update traefik' , t => {
13
13
// handle correct request
14
- const updateServer = nock ( 'http://localhost:8080' ) . post ( '/update/traefik' ) . reply ( 200 , { updated : true } ) ;
14
+ const updateServer = nock ( 'http://localhost:8080' )
15
+ . post ( '/update/traefik' )
16
+ . reply ( 200 , { updated : true } ) ;
15
17
// spy on console
16
18
const consoleSpy = sinon . spy ( console , 'log' ) ;
17
19
// execute login
@@ -32,11 +34,39 @@ module.exports = () => {
32
34
} ) ;
33
35
} ) ;
34
36
37
+ // test update
38
+ tap . test ( 'Should update server' , t => {
39
+ // handle correct request
40
+ const updateServer = nock ( 'http://localhost:8080' )
41
+ . post ( '/update/server' )
42
+ . reply ( 200 , { updated : true } ) ;
43
+ // spy on console
44
+ const consoleSpy = sinon . spy ( console , 'log' ) ;
45
+ // execute login
46
+ update ( { target : 'server' } ) . then ( ( ) => {
47
+ // make sure log in was successful
48
+ // check that server was called
49
+ t . ok ( updateServer . isDone ( ) ) ;
50
+ // first check console output
51
+ t . deepEqual (
52
+ consoleSpy . args ,
53
+ [ [ 'Updating server on:' , 'http://localhost:8080' ] , [ 'Successfully updated server!' ] ] ,
54
+ 'Correct log output'
55
+ ) ;
56
+ // restore console
57
+ console . log . restore ( ) ;
58
+ updateServer . done ( ) ;
59
+ t . end ( ) ;
60
+ } ) ;
61
+ } ) ;
62
+
35
63
// test update error
36
64
tap . test ( 'Should display update error' , t => {
37
65
// handle correct request
38
66
const response = { updated : false , error : 'Test error' , log : 'log' } ;
39
- const updateServer = nock ( 'http://localhost:8080' ) . post ( '/update/traefik' ) . reply ( 500 , response ) ;
67
+ const updateServer = nock ( 'http://localhost:8080' )
68
+ . post ( '/update/traefik' )
69
+ . reply ( 500 , response ) ;
40
70
// spy on console
41
71
const consoleSpy = sinon . spy ( console , 'log' ) ;
42
72
// execute login
@@ -67,7 +97,9 @@ module.exports = () => {
67
97
// copy original config for restoration
68
98
const originalConfig = Object . assign ( { } , userConfig ) ;
69
99
// handle correct request
70
- const updateServer = nock ( 'http://localhost:8080' ) . post ( `/update/traefik` ) . reply ( 401 ) ;
100
+ const updateServer = nock ( 'http://localhost:8080' )
101
+ . post ( `/update/traefik` )
102
+ . reply ( 401 ) ;
71
103
// spy on console
72
104
const consoleSpy = sinon . spy ( console , 'log' ) ;
73
105
// execute login
0 commit comments