(t *testing.T)
| 531 | } |
| 532 | |
| 533 | func TestParseAll(t *testing.T) { |
| 534 | for i, test := range []struct { |
| 535 | input string |
| 536 | shouldErr bool |
| 537 | keys [][]string // keys per server block, in order |
| 538 | }{ |
| 539 | {`localhost`, false, [][]string{ |
| 540 | {"localhost"}, |
| 541 | }}, |
| 542 | |
| 543 | {`localhost:1234`, false, [][]string{ |
| 544 | {"localhost:1234"}, |
| 545 | }}, |
| 546 | |
| 547 | {`localhost:1234 { |
| 548 | } |
| 549 | localhost:2015 { |
| 550 | }`, false, [][]string{ |
| 551 | {"localhost:1234"}, |
| 552 | {"localhost:2015"}, |
| 553 | }}, |
| 554 | |
| 555 | {`localhost:1234, http://host2`, false, [][]string{ |
| 556 | {"localhost:1234", "http://host2"}, |
| 557 | }}, |
| 558 | |
| 559 | {`foo.example.com , example.com`, false, [][]string{ |
| 560 | {"foo.example.com", "example.com"}, |
| 561 | }}, |
| 562 | |
| 563 | {`localhost:1234, http://host2,`, true, [][]string{}}, |
| 564 | |
| 565 | {`http://host1.com, http://host2.com { |
| 566 | } |
| 567 | https://host3.com, https://host4.com { |
| 568 | }`, false, [][]string{ |
| 569 | {"http://host1.com", "http://host2.com"}, |
| 570 | {"https://host3.com", "https://host4.com"}, |
| 571 | }}, |
| 572 | |
| 573 | {`import testdata/import_glob*.txt`, false, [][]string{ |
| 574 | {"glob0.host0"}, |
| 575 | {"glob0.host1"}, |
| 576 | {"glob1.host0"}, |
| 577 | {"glob2.host0"}, |
| 578 | }}, |
| 579 | |
| 580 | {`import notfound/*`, false, [][]string{}}, // glob needn't error with no matches |
| 581 | {`import notfound/file.conf`, true, [][]string{}}, // but a specific file should |
| 582 | |
| 583 | // recursive self-import |
| 584 | {`import testdata/import_recursive0.txt`, true, [][]string{}}, |
| 585 | {`import testdata/import_recursive3.txt |
| 586 | import testdata/import_recursive1.txt`, true, [][]string{}}, |
| 587 | |
| 588 | // cyclic imports |
| 589 | {`(A) { |
| 590 | import A |
nothing calls this directly
no test coverage detected