MCPcopy Index your code
hub / github.com/coder/coder / findDevcontainerByID

Function findDevcontainerByID

agent/agentcontainers/devcontainercli_test.go:629–640  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

627// findDevcontainerByID locates a container by its ID and verifies it has our
628// test label. Returns the container and whether it was found.
629func 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.

Callers 1

Calls 3

HelperMethod · 0.65
LogfMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected