(t *testing.T)
| 411 | } |
| 412 | |
| 413 | func TestCheckConsistency(t *testing.T) { |
| 414 | cases := []struct { |
| 415 | fi FileInfo |
| 416 | ok bool |
| 417 | }{ |
| 418 | { |
| 419 | // valid |
| 420 | fi: FileInfo{ |
| 421 | Name: "foo", |
| 422 | Type: FileInfoTypeFile, |
| 423 | Blocks: []BlockInfo{{Size: 1234, Offset: 0, Hash: []byte{1, 2, 3, 4}}}, |
| 424 | }, |
| 425 | ok: true, |
| 426 | }, |
| 427 | { |
| 428 | // deleted with blocks |
| 429 | fi: FileInfo{ |
| 430 | Name: "foo", |
| 431 | Deleted: true, |
| 432 | Type: FileInfoTypeFile, |
| 433 | Blocks: []BlockInfo{{Size: 1234, Offset: 0, Hash: []byte{1, 2, 3, 4}}}, |
| 434 | }, |
| 435 | ok: false, |
| 436 | }, |
| 437 | { |
| 438 | // no blocks |
| 439 | fi: FileInfo{ |
| 440 | Name: "foo", |
| 441 | Type: FileInfoTypeFile, |
| 442 | }, |
| 443 | ok: false, |
| 444 | }, |
| 445 | { |
| 446 | // directory with blocks |
| 447 | fi: FileInfo{ |
| 448 | Name: "foo", |
| 449 | Type: FileInfoTypeDirectory, |
| 450 | Blocks: []BlockInfo{{Size: 1234, Offset: 0, Hash: []byte{1, 2, 3, 4}}}, |
| 451 | }, |
| 452 | ok: false, |
| 453 | }, |
| 454 | } |
| 455 | |
| 456 | for _, tc := range cases { |
| 457 | err := checkFileInfoConsistency(tc.fi) |
| 458 | if tc.ok && err != nil { |
| 459 | t.Errorf("Unexpected error %v (want nil) for %v", err, tc.fi) |
| 460 | } |
| 461 | if !tc.ok && err == nil { |
| 462 | t.Errorf("Unexpected nil error for %v", tc.fi) |
| 463 | } |
| 464 | } |
| 465 | } |
| 466 | |
| 467 | func TestBlockSize(t *testing.T) { |
| 468 | cases := []struct { |
nothing calls this directly
no test coverage detected