@@ -17,34 +17,51 @@ test('errors when not run on linux platform', async () => {
17
17
expect ( coreSpy ) . toHaveBeenCalledWith ( 'Only supported on linux platform' ) ;
18
18
} ) ;
19
19
20
+ test ( 'errors without username' , async ( ) => {
21
+ const platSpy = jest . spyOn ( osm , 'platform' ) ;
22
+ platSpy . mockImplementation ( ( ) => 'linux' ) ;
23
+
24
+ const coreSpy : jest . SpyInstance = jest . spyOn ( core , 'setFailed' ) ;
25
+
26
+ await run ( ) ;
27
+
28
+ expect ( coreSpy ) . toHaveBeenCalledWith ( 'Input required and not supplied: username' ) ;
29
+ } ) ;
30
+
20
31
test ( 'errors without password' , async ( ) => {
21
32
const platSpy = jest . spyOn ( osm , 'platform' ) ;
22
33
platSpy . mockImplementation ( ( ) => 'linux' ) ;
23
34
24
35
const coreSpy : jest . SpyInstance = jest . spyOn ( core , 'setFailed' ) ;
25
36
37
+ const username : string = 'dbowie' ;
38
+ process . env [ `INPUT_USERNAME` ] = username ;
39
+
26
40
await run ( ) ;
27
41
28
42
expect ( coreSpy ) . toHaveBeenCalledWith ( 'Input required and not supplied: password' ) ;
29
43
} ) ;
30
44
31
- test ( 'successful with only password' , async ( ) => {
32
- const platSpy = jest . spyOn ( osm , 'platform' ) ;
33
- platSpy . mockImplementation ( ( ) => 'linux' ) ;
34
-
35
- const setRegistrySpy : jest . SpyInstance = jest . spyOn ( stateHelper , 'setRegistry' ) ;
36
- const setLogoutSpy : jest . SpyInstance = jest . spyOn ( stateHelper , 'setLogout' ) ;
37
- const dockerSpy : jest . SpyInstance = jest . spyOn ( docker , 'login' ) ;
38
- dockerSpy . mockImplementation ( ( ) => { } ) ;
39
-
40
- const password : string = 'groundcontrol' ;
41
- process . env [ `INPUT_PASSWORD` ] = password ;
42
-
43
- await run ( ) ;
44
-
45
- expect ( setRegistrySpy ) . toHaveBeenCalledWith ( '' ) ;
46
- expect ( setLogoutSpy ) . toHaveBeenCalledWith ( '' ) ;
47
- expect ( dockerSpy ) . toHaveBeenCalledWith ( '' , '' , password ) ;
45
+ test ( 'successful with username and password' , async ( ) => {
46
+ const platSpy = jest . spyOn ( osm , 'platform' ) ;
47
+ platSpy . mockImplementation ( ( ) => 'linux' ) ;
48
+
49
+ const setRegistrySpy : jest . SpyInstance = jest . spyOn ( stateHelper , 'setRegistry' ) ;
50
+ const setLogoutSpy : jest . SpyInstance = jest . spyOn ( stateHelper , 'setLogout' ) ;
51
+ const dockerSpy : jest . SpyInstance = jest . spyOn ( docker , 'login' ) ;
52
+ dockerSpy . mockImplementation ( ( ) => { } ) ;
53
+
54
+ const username : string = 'dbowie' ;
55
+ process . env [ `INPUT_USERNAME` ] = username ;
56
+
57
+ const password : string = 'groundcontrol' ;
58
+ process . env [ `INPUT_PASSWORD` ] = password ;
59
+
60
+ await run ( ) ;
61
+
62
+ expect ( setRegistrySpy ) . toHaveBeenCalledWith ( '' ) ;
63
+ expect ( setLogoutSpy ) . toHaveBeenCalledWith ( '' ) ;
64
+ expect ( dockerSpy ) . toHaveBeenCalledWith ( '' , username , password ) ;
48
65
} ) ;
49
66
50
67
test ( 'calls docker login' , async ( ) => {
@@ -66,7 +83,7 @@ test('calls docker login', async () => {
66
83
process . env [ `INPUT_REGISTRY` ] = registry ;
67
84
68
85
const logout : string = 'true' ;
69
- process . env [ 'INPUT_LOGOUT' ] = logout
86
+ process . env [ 'INPUT_LOGOUT' ] = logout ;
70
87
71
88
await run ( ) ;
72
89
0 commit comments