| 118 | } |
| 119 | |
| 120 | func 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 | } |