(t *testing.T)
| 17 | } |
| 18 | |
| 19 | func TestCreateBlobFromBuffer(t *testing.T) { |
| 20 | t.Parallel() |
| 21 | repo := createTestRepo(t) |
| 22 | defer cleanupTestRepo(t, repo) |
| 23 | |
| 24 | id, err := repo.CreateBlobFromBuffer(make([]byte, 0)) |
| 25 | checkFatal(t, err) |
| 26 | |
| 27 | if id.String() != "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391" { |
| 28 | t.Fatal("Empty buffer did not deliver empty blob id") |
| 29 | } |
| 30 | |
| 31 | tests := []struct { |
| 32 | data []byte |
| 33 | isBinary bool |
| 34 | }{ |
| 35 | { |
| 36 | data: []byte("hello there"), |
| 37 | isBinary: false, |
| 38 | }, |
| 39 | { |
| 40 | data: doublePointerBytes(), |
| 41 | isBinary: true, |
| 42 | }, |
| 43 | } |
| 44 | for _, tt := range tests { |
| 45 | data := tt.data |
| 46 | id, err = repo.CreateBlobFromBuffer(data) |
| 47 | checkFatal(t, err) |
| 48 | |
| 49 | blob, err := repo.LookupBlob(id) |
| 50 | checkFatal(t, err) |
| 51 | if !bytes.Equal(blob.Contents(), data) { |
| 52 | t.Fatal("Loaded bytes don't match original bytes:", |
| 53 | blob.Contents(), "!=", data) |
| 54 | } |
| 55 | want := tt.isBinary |
| 56 | if got := blob.IsBinary(); got != want { |
| 57 | t.Fatalf("IsBinary() = %v, want %v", got, want) |
| 58 | } |
| 59 | } |
| 60 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…