(t *testing.T)
| 556 | } |
| 557 | |
| 558 | func TestComposeIPAMConfig(t *testing.T) { |
| 559 | testCase := nerdtest.Setup() |
| 560 | |
| 561 | testCase.Setup = func(data test.Data, helpers test.Helpers) { |
| 562 | var composeYAML = fmt.Sprintf(` |
| 563 | services: |
| 564 | foo: |
| 565 | image: %s |
| 566 | command: "sleep infinity" |
| 567 | |
| 568 | networks: |
| 569 | default: |
| 570 | ipam: |
| 571 | config: |
| 572 | - subnet: 10.1.100.0/24 |
| 573 | `, testutil.CommonImage) |
| 574 | |
| 575 | composePath := data.Temp().Save(composeYAML, "compose.yaml") |
| 576 | |
| 577 | projectName := filepath.Base(filepath.Dir(composePath)) |
| 578 | t.Logf("projectName=%q", projectName) |
| 579 | |
| 580 | fooContainer := serviceparser.DefaultContainerName(projectName, "foo", "1") |
| 581 | |
| 582 | data.Labels().Set("composeYAML", composePath) |
| 583 | data.Labels().Set("fooContainer", fooContainer) |
| 584 | |
| 585 | helpers.Ensure("compose", "-f", composePath, "up", "-d") |
| 586 | nerdtest.EnsureContainerStarted(helpers, fooContainer) |
| 587 | } |
| 588 | |
| 589 | testCase.Command = func(data test.Data, helpers test.Helpers) test.TestableCommand { |
| 590 | return helpers.Command("inspect", "-f", "{{json .NetworkSettings.Networks }}", data.Labels().Get("fooContainer")) |
| 591 | } |
| 592 | |
| 593 | testCase.Expected = test.Expects(0, nil, expect.Contains("10.1.100.")) |
| 594 | |
| 595 | testCase.Cleanup = func(data test.Data, helpers test.Helpers) { |
| 596 | if data.Labels().Get("composeYAML") != "" { |
| 597 | helpers.Anyhow("compose", "-f", data.Labels().Get("composeYAML"), "down", "-v") |
| 598 | } |
| 599 | } |
| 600 | |
| 601 | testCase.Run(t) |
| 602 | } |
| 603 | |
| 604 | func TestComposeUpRemoveOrphans(t *testing.T) { |
| 605 | testCase := nerdtest.Setup() |
nothing calls this directly
no test coverage detected
searching dependent graphs…