findDevcontainerByID locates a container by its ID and verifies it has our test label. Returns the container and whether it was found.
(t *testing.T, pool *dockertest.Pool, id string)
| 627 | // findDevcontainerByID locates a container by its ID and verifies it has our |
| 628 | // test label. Returns the container and whether it was found. |
| 629 | func findDevcontainerByID(t *testing.T, pool *dockertest.Pool, id string) (*docker.Container, bool) { |
| 630 | t.Helper() |
| 631 | |
| 632 | container, err := pool.Client.InspectContainer(id) |
| 633 | if err != nil { |
| 634 | t.Logf("Inspect container failed: %v", err) |
| 635 | return nil, false |
| 636 | } |
| 637 | require.Equal(t, "devcontainercli", container.Config.Labels["com.coder.test"], "sanity check failed: container should have the test label") |
| 638 | |
| 639 | return container, true |
| 640 | } |
| 641 | |
| 642 | // removeDevcontainerByID safely cleans up a test container by ID, verifying |
| 643 | // it has our test label before removal to prevent accidental deletion. |
no test coverage detected