MCPcopy
hub / github.com/basecamp/once / TestUpdateDetectsLocalImageChange

Function TestUpdateDetectsLocalImageChange

integration/docker_test.go:151–187  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

149}
150
151func TestUpdateDetectsLocalImageChange(t *testing.T) {
152 ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
153 defer cancel()
154
155 registryURL := startLocalRegistry(t, ctx)
156 imageTag := registryURL + "/update-test:latest"
157
158 buildAndPushImage(t, ctx, imageTag, "v1")
159
160 ns, err := docker.NewNamespace("once-update-test")
161 require.NoError(t, err)
162 defer ns.Teardown(ctx, true)
163
164 require.NoError(t, ns.EnsureNetwork(ctx))
165 require.NoError(t, ns.Proxy().Boot(ctx, getProxyPorts(t)))
166
167 app := deployApp(t, ctx, ns, docker.ApplicationSettings{
168 Name: "updateapp",
169 Image: imageTag,
170 Host: "updateapp.localhost",
171 })
172
173 firstContainer, err := app.ContainerName(ctx)
174 require.NoError(t, err)
175
176 // Build v2 with the same tag. The local tag now points to a newer image
177 // than what the running container uses.
178 buildAndPushImage(t, ctx, imageTag, "v2")
179
180 changed, err := app.Update(ctx, nil)
181 require.NoError(t, err)
182 assert.True(t, changed, "Update should detect the newer local image")
183
184 secondContainer, err := app.ContainerName(ctx)
185 require.NoError(t, err)
186 assert.NotEqual(t, firstContainer, secondContainer, "container should change after update")
187}
188
189func TestLargeLabelData(t *testing.T) {
190 ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)

Callers

nothing calls this directly

Calls 11

TeardownMethod · 0.95
EnsureNetworkMethod · 0.95
ProxyMethod · 0.95
NewNamespaceFunction · 0.92
startLocalRegistryFunction · 0.85
buildAndPushImageFunction · 0.85
getProxyPortsFunction · 0.85
deployAppFunction · 0.85
BootMethod · 0.80
ContainerNameMethod · 0.80
UpdateMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…