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

Function TestConvertDockerInspect

agent/agentcontainers/containers_internal_test.go:159–412  ·  view source on GitHub ↗

TestConvertDockerInspect tests the convertDockerInspect function using fixtures from ./testdata.

(t *testing.T)

Source from the content-addressed store, hash-verified

157// TestConvertDockerInspect tests the convertDockerInspect function using
158// fixtures from ./testdata.
159func TestConvertDockerInspect(t *testing.T) {
160 t.Parallel()
161
162 for _, tt := range []struct {
163 name string
164 expect []codersdk.WorkspaceAgentContainer
165 expectWarns []string
166 expectError string
167 }{
168 {
169 name: "container_simple",
170 expect: []codersdk.WorkspaceAgentContainer{
171 {
172 CreatedAt: time.Date(2025, 3, 11, 17, 55, 58, 91280203, time.UTC),
173 ID: "6b539b8c60f5230b8b0fde2502cd2332d31c0d526a3e6eb6eef1cc39439b3286",
174 FriendlyName: "eloquent_kowalevski",
175 Image: "debian:bookworm",
176 Labels: map[string]string{},
177 Running: true,
178 Status: "running",
179 Ports: []codersdk.WorkspaceAgentContainerPort{},
180 Volumes: map[string]string{},
181 },
182 },
183 },
184 {
185 name: "container_labels",
186 expect: []codersdk.WorkspaceAgentContainer{
187 {
188 CreatedAt: time.Date(2025, 3, 11, 20, 3, 28, 71706536, time.UTC),
189 ID: "bd8818e670230fc6f36145b21cf8d6d35580355662aa4d9fe5ae1b188a4c905f",
190 FriendlyName: "fervent_bardeen",
191 Image: "debian:bookworm",
192 Labels: map[string]string{"baz": "zap", "foo": "bar"},
193 Running: true,
194 Status: "running",
195 Ports: []codersdk.WorkspaceAgentContainerPort{},
196 Volumes: map[string]string{},
197 },
198 },
199 },
200 {
201 name: "container_binds",
202 expect: []codersdk.WorkspaceAgentContainer{
203 {
204 CreatedAt: time.Date(2025, 3, 11, 17, 58, 43, 522505027, time.UTC),
205 ID: "fdc75ebefdc0243c0fce959e7685931691ac7aede278664a0e2c23af8a1e8d6a",
206 FriendlyName: "silly_beaver",
207 Image: "debian:bookworm",
208 Labels: map[string]string{},
209 Running: true,
210 Status: "running",
211 Ports: []codersdk.WorkspaceAgentContainerPort{},
212 Volumes: map[string]string{
213 "/tmp/test/a": "/var/coder/a",
214 "/tmp/test/b": "/var/coder/b",
215 },
216 },

Callers

nothing calls this directly

Calls 7

convertDockerInspectFunction · 0.85
RunMethod · 0.65
ReadFileMethod · 0.65
LenMethod · 0.45
ContainsMethod · 0.45
EmptyMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected