(t *testing.T)
| 1352 | } |
| 1353 | |
| 1354 | func TestPutFileIfExistsSkipReturnsNonFileConflicts(t *testing.T) { |
| 1355 | tests := []struct { |
| 1356 | name string |
| 1357 | conflictTag string |
| 1358 | }{ |
| 1359 | {"folder", files.WriteConflictErrorFolder}, |
| 1360 | {"file ancestor", files.WriteConflictErrorFileAncestor}, |
| 1361 | {"other", files.WriteConflictErrorOther}, |
| 1362 | } |
| 1363 | |
| 1364 | for _, tt := range tests { |
| 1365 | t.Run(tt.name, func(t *testing.T) { |
| 1366 | tmpFile := filepath.Join(t.TempDir(), "test.txt") |
| 1367 | if err := os.WriteFile(tmpFile, []byte("test"), 0644); err != nil { |
| 1368 | t.Fatal(err) |
| 1369 | } |
| 1370 | |
| 1371 | mock := &mockFilesClient{ |
| 1372 | getMetadataFn: func(arg *files.GetMetadataArg) (files.IsMetadata, error) { |
| 1373 | return nil, getMetadataNotFoundError() |
| 1374 | }, |
| 1375 | uploadFn: func(arg *files.UploadArg, content io.Reader) (*files.FileMetadata, error) { |
| 1376 | return nil, uploadPathConflictError(tt.conflictTag) |
| 1377 | }, |
| 1378 | } |
| 1379 | stubFilesClient(t, mock) |
| 1380 | |
| 1381 | stderr := captureStderr(t, func() { |
| 1382 | err := putFile(tmpFile, "/bad-conflict.txt", putOptions{ |
| 1383 | chunkSize: 1 << 24, |
| 1384 | workers: 4, |
| 1385 | ifExists: putIfExistsSkip, |
| 1386 | }) |
| 1387 | if err == nil { |
| 1388 | t.Fatal("expected non-file conflict error") |
| 1389 | } |
| 1390 | }) |
| 1391 | if strings.Contains(stderr, "Skipping ") { |
| 1392 | t.Fatalf("stderr = %q, should not skip non-file conflicts", stderr) |
| 1393 | } |
| 1394 | }) |
| 1395 | } |
| 1396 | } |
| 1397 | |
| 1398 | func TestIsUploadDestinationFileConflict(t *testing.T) { |
| 1399 | tests := []struct { |
nothing calls this directly
no test coverage detected