MCPcopy
hub / github.com/docker/compose / TestToObservedContainer

Function TestToObservedContainer

pkg/compose/observed_state_test.go:34–63  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

32)
33
34func TestToObservedContainer(t *testing.T) {
35 c := container.Summary{
36 ID: "abc123",
37 Names: []string{"/testProject-web-1"},
38 State: container.StateRunning,
39 Labels: map[string]string{
40 api.ServiceLabel: "web",
41 api.ConfigHashLabel: "sha256:aaa",
42 api.ImageDigestLabel: "sha256:bbb",
43 api.ContainerNumberLabel: "1",
44 api.ProjectLabel: "testproject",
45 },
46 NetworkSettings: &container.NetworkSettingsSummary{
47 Networks: map[string]*network.EndpointSettings{
48 "mynet": {NetworkID: "net123"},
49 },
50 },
51 }
52
53 oc := toObservedContainer(c)
54
55 assert.Equal(t, oc.ID, "abc123")
56 assert.Equal(t, oc.Name, "testProject-web-1")
57 assert.Equal(t, oc.State, container.StateRunning)
58 assert.Equal(t, oc.ConfigHash, "sha256:aaa")
59 assert.Equal(t, oc.ImageDigest, "sha256:bbb")
60 assert.Equal(t, oc.Number, 1)
61 assert.Equal(t, oc.ConnectedNetworks["mynet"], "net123")
62 assert.Equal(t, oc.Summary.ID, "abc123")
63}
64
65func TestToObservedContainerNoNetworkSettings(t *testing.T) {
66 c := container.Summary{

Callers

nothing calls this directly

Calls 1

toObservedContainerFunction · 0.85

Tested by

no test coverage detected