MCPcopy Create free account
hub / github.com/dropbox/dbxcli / TestPutFileIfExistsFailUploadsMissingFileWithAddMode

Function TestPutFileIfExistsFailUploadsMissingFileWithAddMode

cmd/put_test.go:1241–1275  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1239}
1240
1241func TestPutFileIfExistsFailUploadsMissingFileWithAddMode(t *testing.T) {
1242 tmpFile := filepath.Join(t.TempDir(), "test.txt")
1243 if err := os.WriteFile(tmpFile, []byte("test"), 0644); err != nil {
1244 t.Fatal(err)
1245 }
1246
1247 var mode string
1248 var strictConflict bool
1249 mock := &mockFilesClient{
1250 getMetadataFn: func(arg *files.GetMetadataArg) (files.IsMetadata, error) {
1251 return nil, getMetadataNotFoundError()
1252 },
1253 uploadFn: func(arg *files.UploadArg, content io.Reader) (*files.FileMetadata, error) {
1254 mode = arg.Mode.Tag
1255 strictConflict = arg.StrictConflict
1256 return &files.FileMetadata{}, nil
1257 },
1258 }
1259 stubFilesClient(t, mock)
1260
1261 err := putFile(tmpFile, "/new.txt", putOptions{
1262 chunkSize: 1 << 24,
1263 workers: 4,
1264 ifExists: putIfExistsFail,
1265 })
1266 if err != nil {
1267 t.Fatalf("putFile error: %v", err)
1268 }
1269 if mode != files.WriteModeAdd {
1270 t.Errorf("write mode = %q, want %q", mode, files.WriteModeAdd)
1271 }
1272 if !strictConflict {
1273 t.Error("strict conflict = false, want true")
1274 }
1275}
1276
1277func TestPutFileIfExistsOverwriteUsesOverwriteMode(t *testing.T) {
1278 tmpFile := filepath.Join(t.TempDir(), "test.txt")

Callers

nothing calls this directly

Calls 4

getMetadataNotFoundErrorFunction · 0.85
stubFilesClientFunction · 0.85
putFileFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected