|
6 | 6 | bindAddrFromArgs,
|
7 | 7 | defaultConfigFile,
|
8 | 8 | parse,
|
| 9 | + parseConfigFile, |
9 | 10 | setDefaults,
|
10 | 11 | shouldOpenInExistingInstance,
|
11 | 12 | toCodeArgs,
|
@@ -287,12 +288,17 @@ describe("parser", () => {
|
287 | 288 | })
|
288 | 289 |
|
289 | 290 | it("should support repeatable flags", async () => {
|
| 291 | + expect(() => parse(["--proxy-domain", ""])).toThrowError(/--proxy-domain requires a value/) |
290 | 292 | expect(parse(["--proxy-domain", "*.coder.com"])).toEqual({
|
291 | 293 | "proxy-domain": ["*.coder.com"],
|
292 | 294 | })
|
293 | 295 | expect(parse(["--proxy-domain", "*.coder.com", "--proxy-domain", "test.com"])).toEqual({
|
294 | 296 | "proxy-domain": ["*.coder.com", "test.com"],
|
295 | 297 | })
|
| 298 | + // Commas are literal, at the moment. |
| 299 | + expect(parse(["--proxy-domain", "*.coder.com,test.com"])).toEqual({ |
| 300 | + "proxy-domain": ["*.coder.com,test.com"], |
| 301 | + }) |
296 | 302 | })
|
297 | 303 |
|
298 | 304 | it("should enforce cert-key with cert value or otherwise generate one", async () => {
|
@@ -490,6 +496,20 @@ describe("parser", () => {
|
490 | 496 | }),
|
491 | 497 | ).toThrowError(expectedErrMsg)
|
492 | 498 | })
|
| 499 | + it("should fail to parse invalid config", () => { |
| 500 | + expect(() => parseConfigFile("test", "/fake-config-path")).toThrowError("invalid config: test") |
| 501 | + }) |
| 502 | + it("should parse repeatable options", () => { |
| 503 | + const configContents = ` |
| 504 | + install-extension: |
| 505 | + - extension.number1 |
| 506 | + - extension.number2 |
| 507 | + ` |
| 508 | + expect(parseConfigFile(configContents, "/fake-config-path")).toEqual({ |
| 509 | + config: "/fake-config-path", |
| 510 | + "install-extension": ["extension.number1", "extension.number2"], |
| 511 | + }) |
| 512 | + }) |
493 | 513 | it("should ignore optional strings set to false", async () => {
|
494 | 514 | expect(parse(["--cert=false"])).toEqual({})
|
495 | 515 | })
|
|
0 commit comments