(t *testing.T)
| 12 | ) |
| 13 | |
| 14 | func TestOdbRead(t *testing.T) { |
| 15 | t.Parallel() |
| 16 | repo := createTestRepo(t) |
| 17 | defer cleanupTestRepo(t, repo) |
| 18 | |
| 19 | _, _ = seedTestRepo(t, repo) |
| 20 | odb, err := repo.Odb() |
| 21 | if err != nil { |
| 22 | t.Fatalf("Odb: %v", err) |
| 23 | } |
| 24 | data := []byte("hello") |
| 25 | id, err := odb.Write(data, ObjectBlob) |
| 26 | if err != nil { |
| 27 | t.Fatalf("odb.Write: %v", err) |
| 28 | } |
| 29 | |
| 30 | sz, typ, err := odb.ReadHeader(id) |
| 31 | if err != nil { |
| 32 | t.Fatalf("ReadHeader: %v", err) |
| 33 | } |
| 34 | |
| 35 | if sz != uint64(len(data)) { |
| 36 | t.Errorf("ReadHeader got size %d, want %d", sz, len(data)) |
| 37 | } |
| 38 | if typ != ObjectBlob { |
| 39 | t.Errorf("ReadHeader got object type %s", typ) |
| 40 | } |
| 41 | |
| 42 | obj, err := odb.Read(id) |
| 43 | if err != nil { |
| 44 | t.Fatalf("Read: %v", err) |
| 45 | } |
| 46 | if !bytes.Equal(obj.Data(), data) { |
| 47 | t.Errorf("Read got wrong data") |
| 48 | } |
| 49 | if sz := obj.Len(); sz != uint64(len(data)) { |
| 50 | t.Errorf("Read got size %d, want %d", sz, len(data)) |
| 51 | } |
| 52 | if typ := obj.Type(); typ != ObjectBlob { |
| 53 | t.Errorf("Read got object type %s", typ) |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | func TestOdbStream(t *testing.T) { |
| 58 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…