@@ -36,7 +36,7 @@ func Test_parseEnvironmentConfig(t *testing.T) {
3636 require .Empty (t , envConfig .DisableFeature )
3737 require .Empty (t , envConfig .EnableFeature )
3838 require .Empty (t , envConfig .SetTheme )
39- require .Empty (t , envConfig .SSHConfigFilePath )
39+ require .Empty (t , envConfig .SSHConfigPath )
4040 require .Equal (t , "info" , envConfig .LogLevel )
4141 })
4242
@@ -52,16 +52,16 @@ func Test_parseEnvironmentConfig(t *testing.T) {
5252 require .Empty (t , envConfig .DisableFeature )
5353 require .Empty (t , envConfig .EnableFeature )
5454 require .Empty (t , envConfig .SetTheme )
55- require .Equal (t , "/tmp/custom_config" , envConfig .SSHConfigFilePath )
55+ require .Equal (t , "/tmp/custom_config" , envConfig .SSHConfigPath )
5656 require .Equal (t , "debug" , envConfig .LogLevel )
5757 })
5858}
5959
6060func Test_parseCommandLineFlags (t * testing.T ) {
6161 envConfig := & Configuration {
62- AppHome : "/tmp/home" ,
63- LogLevel : "info" ,
64- SSHConfigFilePath : "/tmp/custom_config" ,
62+ AppHome : "/tmp/home" ,
63+ LogLevel : "info" ,
64+ SSHConfigPath : "/tmp/custom_config" ,
6565 }
6666
6767 tests := []struct {
@@ -74,116 +74,130 @@ func Test_parseCommandLineFlags(t *testing.T) {
7474 name : "No command line flags" ,
7575 args : []string {},
7676 wantConfig : & Configuration {
77- AppHome : "/tmp/home" ,
78- AppMode : "" ,
79- DisableFeature : "" ,
80- EnableFeature : "" ,
81- LogLevel : "info" ,
82- SSHConfigFilePath : "/tmp/custom_config" ,
77+ AppHome : "/tmp/home" ,
78+ AppMode : "" ,
79+ DisableFeature : "" ,
80+ EnableFeature : "" ,
81+ LogLevel : "info" ,
82+ SSHConfigPath : "/tmp/custom_config" ,
8383 },
8484 wantError : false ,
8585 }, {
8686 name : "Display help" ,
8787 args : []string {"-h" },
8888 wantConfig : & Configuration {
89- AppHome : "/tmp/home" ,
90- AppMode : "" ,
91- DisableFeature : "" ,
92- EnableFeature : "" ,
93- LogLevel : "info" ,
94- SSHConfigFilePath : "/tmp/custom_config" ,
95- SetTheme : "" ,
89+ AppHome : "/tmp/home" ,
90+ AppMode : "" ,
91+ DisableFeature : "" ,
92+ EnableFeature : "" ,
93+ LogLevel : "info" ,
94+ SSHConfigPath : "/tmp/custom_config" ,
95+ SetTheme : "" ,
9696 },
9797 wantError : true , // returns flag.ErrHelp, read the os.flag documentation for details
9898 }, {
9999 name : "Display version" ,
100100 args : []string {"-v" },
101101 wantConfig : & Configuration {
102- AppHome : "/tmp/home" ,
103- AppMode : "DISPLAY_INFO" ,
104- DisableFeature : "" ,
105- EnableFeature : "" ,
106- LogLevel : "info" ,
107- SSHConfigFilePath : "/tmp/custom_config" ,
108- SetTheme : "" ,
102+ AppHome : "/tmp/home" ,
103+ AppMode : "DISPLAY_INFO" ,
104+ DisableFeature : "" ,
105+ EnableFeature : "" ,
106+ LogLevel : "info" ,
107+ SSHConfigPath : "/tmp/custom_config" ,
108+ SetTheme : "" ,
109109 },
110110 wantError : false ,
111111 }, {
112112 name : "Set home app folder" ,
113113 args : []string {"-f" , "/tmp/home2" },
114114 wantConfig : & Configuration {
115- AppHome : "/tmp/home2" ,
116- AppMode : "" ,
117- DisableFeature : "" ,
118- EnableFeature : "" ,
119- LogLevel : "info" ,
120- SSHConfigFilePath : "/tmp/custom_config" ,
121- SetTheme : "" ,
115+ AppHome : "/tmp/home2" ,
116+ AppMode : "" ,
117+ DisableFeature : "" ,
118+ EnableFeature : "" ,
119+ LogLevel : "info" ,
120+ SSHConfigPath : "/tmp/custom_config" ,
121+ SetTheme : "" ,
122122 },
123123 wantError : false ,
124124 }, {
125125 name : "Set log level" ,
126126 args : []string {"-l" , "debug" },
127127 wantConfig : & Configuration {
128- AppHome : "/tmp/home" ,
129- AppMode : "" ,
130- DisableFeature : "" ,
131- EnableFeature : "" ,
132- LogLevel : "debug" ,
133- SSHConfigFilePath : "/tmp/custom_config" ,
134- SetTheme : "" ,
128+ AppHome : "/tmp/home" ,
129+ AppMode : "" ,
130+ DisableFeature : "" ,
131+ EnableFeature : "" ,
132+ LogLevel : "debug" ,
133+ SSHConfigPath : "/tmp/custom_config" ,
134+ SetTheme : "" ,
135135 },
136136 wantError : false ,
137137 }, {
138138 name : "Set SSH config file path" ,
139139 args : []string {"-s" , "/tmp/custom_config2" },
140140 wantConfig : & Configuration {
141- AppHome : "/tmp/home" ,
142- AppMode : "" ,
143- DisableFeature : "" ,
144- EnableFeature : "" ,
145- LogLevel : "info" ,
146- SSHConfigFilePath : "/tmp/custom_config2" ,
147- SetTheme : "" ,
141+ AppHome : "/tmp/home" ,
142+ AppMode : "" ,
143+ DisableFeature : "" ,
144+ EnableFeature : "" ,
145+ LogLevel : "info" ,
146+ SSHConfigPath : "/tmp/custom_config2" ,
147+ SetTheme : "" ,
148148 },
149149 wantError : false ,
150150 }, {
151151 name : "Set theme" ,
152152 args : []string {"--set-theme" , "dark" },
153153 wantConfig : & Configuration {
154- AppHome : "/tmp/home" ,
155- AppMode : "HANDLE_PARAM" ,
156- DisableFeature : "" ,
157- EnableFeature : "" ,
158- LogLevel : "info" ,
159- SSHConfigFilePath : "/tmp/custom_config" ,
160- SetTheme : "dark" ,
154+ AppHome : "/tmp/home" ,
155+ AppMode : "HANDLE_PARAM" ,
156+ DisableFeature : "" ,
157+ EnableFeature : "" ,
158+ LogLevel : "info" ,
159+ SSHConfigPath : "/tmp/custom_config" ,
160+ SetTheme : "dark" ,
161161 },
162162 wantError : false ,
163163 }, {
164164 name : "Enable feature" ,
165165 args : []string {"-e" , "ssh_config" },
166166 wantConfig : & Configuration {
167- AppHome : "/tmp/home" ,
168- AppMode : "HANDLE_PARAM" ,
169- DisableFeature : "" ,
170- EnableFeature : "ssh_config" ,
171- LogLevel : "info" ,
172- SSHConfigFilePath : "/tmp/custom_config" ,
173- SetTheme : "" ,
167+ AppHome : "/tmp/home" ,
168+ AppMode : "HANDLE_PARAM" ,
169+ DisableFeature : "" ,
170+ EnableFeature : "ssh_config" ,
171+ LogLevel : "info" ,
172+ SSHConfigPath : "/tmp/custom_config" ,
173+ SetTheme : "" ,
174174 },
175175 wantError : false ,
176176 }, {
177177 name : "Disable feature" ,
178178 args : []string {"-d" , "ssh_config" },
179179 wantConfig : & Configuration {
180- AppHome : "/tmp/home" ,
181- AppMode : "HANDLE_PARAM" ,
182- DisableFeature : "ssh_config" ,
183- EnableFeature : "" ,
184- LogLevel : "info" ,
185- SSHConfigFilePath : "/tmp/custom_config" ,
186- SetTheme : "" ,
180+ AppHome : "/tmp/home" ,
181+ AppMode : "HANDLE_PARAM" ,
182+ DisableFeature : "ssh_config" ,
183+ EnableFeature : "" ,
184+ LogLevel : "info" ,
185+ SSHConfigPath : "/tmp/custom_config" ,
186+ SetTheme : "" ,
187+ },
188+ wantError : false ,
189+ }, {
190+ name : "Set ssh config path" ,
191+ args : []string {"--set-ssh-config-path" , "/tmp/custom_config2" },
192+ wantConfig : & Configuration {
193+ AppHome : "/tmp/home" ,
194+ AppMode : "HANDLE_PARAM" ,
195+ DisableFeature : "" ,
196+ EnableFeature : "" ,
197+ LogLevel : "info" ,
198+ SSHConfigPath : "/tmp/custom_config" , // this comes from env config, see above
199+ SetSSHConfigPath : "/tmp/custom_config2" ,
200+ SetTheme : "" ,
187201 },
188202 wantError : false ,
189203 },
@@ -207,7 +221,8 @@ func Test_parseCommandLineFlags(t *testing.T) {
207221 require .Equal (t , tt .wantConfig .DisableFeature , cfg .DisableFeature )
208222 require .Equal (t , tt .wantConfig .EnableFeature , cfg .EnableFeature )
209223 require .Equal (t , tt .wantConfig .LogLevel , cfg .LogLevel )
210- require .Equal (t , tt .wantConfig .SSHConfigFilePath , cfg .SSHConfigFilePath )
224+ require .Equal (t , tt .wantConfig .SSHConfigPath , cfg .SSHConfigPath )
225+ require .Equal (t , tt .wantConfig .SetSSHConfigPath , cfg .SetSSHConfigPath )
211226 require .Equal (t , tt .wantConfig .SetTheme , cfg .SetTheme )
212227 })
213228 }
0 commit comments