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

Function TestSync_MixedPaths

internal/sync/tar_test.go:120–139  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

118}
119
120func TestSync_MixedPaths(t *testing.T) {
121 tmpDir := t.TempDir()
122 existingFile := filepath.Join(tmpDir, "keep.txt")
123 assert.NilError(t, os.WriteFile(existingFile, []byte("data"), 0o644))
124
125 client := &fakeLowLevelClient{
126 containers: []container.Summary{{ID: "ctr1"}},
127 }
128 tar := NewTar("proj", client)
129
130 err := tar.Sync(t.Context(), "svc", []*PathMapping{
131 {HostPath: existingFile, ContainerPath: "/app/keep.txt"},
132 {HostPath: "/no/such/path", ContainerPath: "/app/removed.txt"},
133 })
134
135 assert.NilError(t, err)
136 assert.Equal(t, client.untarCount, 1, "existing path should be copied")
137 assert.Equal(t, len(client.execCmds), 1)
138 assert.Check(t, cmp.Contains(client.execCmds[0][len(client.execCmds[0])-1], "removed.txt"))
139}

Callers

nothing calls this directly

Calls 4

SyncMethod · 0.95
NewTarFunction · 0.85
TempDirMethod · 0.80
WriteFileMethod · 0.80

Tested by

no test coverage detected