@@ -17,34 +17,51 @@ test('errors when not run on linux platform', async () => {
1717 expect ( coreSpy ) . toHaveBeenCalledWith ( 'Only supported on linux platform' ) ;
1818} ) ;
1919
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+
2031test ( 'errors without password' , async ( ) => {
2132 const platSpy = jest . spyOn ( osm , 'platform' ) ;
2233 platSpy . mockImplementation ( ( ) => 'linux' ) ;
2334
2435 const coreSpy : jest . SpyInstance = jest . spyOn ( core , 'setFailed' ) ;
2536
37+ const username : string = 'dbowie' ;
38+ process . env [ `INPUT_USERNAME` ] = username ;
39+
2640 await run ( ) ;
2741
2842 expect ( coreSpy ) . toHaveBeenCalledWith ( 'Input required and not supplied: password' ) ;
2943} ) ;
3044
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 ) ;
4865} ) ;
4966
5067test ( 'calls docker login' , async ( ) => {
@@ -66,7 +83,7 @@ test('calls docker login', async () => {
6683 process . env [ `INPUT_REGISTRY` ] = registry ;
6784
6885 const logout : string = 'true' ;
69- process . env [ 'INPUT_LOGOUT' ] = logout
86+ process . env [ 'INPUT_LOGOUT' ] = logout ;
7087
7188 await run ( ) ;
7289
0 commit comments