(t *testing.T)
| 269 | } |
| 270 | |
| 271 | func TestConfigSSH_FileWriteAndOptionsFlow(t *testing.T) { |
| 272 | t.Parallel() |
| 273 | |
| 274 | headerStart := strings.Join([]string{ |
| 275 | "# ------------START-CODER-----------", |
| 276 | "# This section is managed by coder. DO NOT EDIT.", |
| 277 | "#", |
| 278 | "# You should not hand-edit this section unless you are removing it, all", |
| 279 | "# changes will be lost when running \"coder config-ssh\".", |
| 280 | "#", |
| 281 | }, "\n") |
| 282 | headerEnd := "# ------------END-CODER------------" |
| 283 | baseHeader := strings.Join([]string{ |
| 284 | headerStart, |
| 285 | headerEnd, |
| 286 | }, "\n") |
| 287 | |
| 288 | type writeConfig struct { |
| 289 | ssh string |
| 290 | } |
| 291 | type wantConfig struct { |
| 292 | ssh []string |
| 293 | regexMatch string |
| 294 | } |
| 295 | type match struct { |
| 296 | match, write string |
| 297 | } |
| 298 | tests := []struct { |
| 299 | name string |
| 300 | args []string |
| 301 | matches []match |
| 302 | writeConfig writeConfig |
| 303 | wantConfig wantConfig |
| 304 | wantErr bool |
| 305 | hasAgent bool |
| 306 | }{ |
| 307 | { |
| 308 | name: "Config file is created", |
| 309 | matches: []match{ |
| 310 | {match: "Continue?", write: "yes"}, |
| 311 | }, |
| 312 | wantConfig: wantConfig{ |
| 313 | ssh: []string{ |
| 314 | headerStart, |
| 315 | headerEnd, |
| 316 | }, |
| 317 | }, |
| 318 | }, |
| 319 | { |
| 320 | name: "Section is written after user content", |
| 321 | writeConfig: writeConfig{ |
| 322 | ssh: strings.Join([]string{ |
| 323 | "Host myhost", |
| 324 | " HostName myhost", |
| 325 | }, "\n"), |
| 326 | }, |
| 327 | wantConfig: wantConfig{ |
| 328 | ssh: []string{ |
nothing calls this directly
no test coverage detected