MCPcopy Create free account
hub / github.com/libgit2/git2go / TestOdbRead

Function TestOdbRead

odb_test.go:14–55  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12)
13
14func 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
57func TestOdbStream(t *testing.T) {
58 t.Parallel()

Callers

nothing calls this directly

Calls 11

createTestRepoFunction · 0.85
cleanupTestRepoFunction · 0.85
seedTestRepoFunction · 0.85
OdbMethod · 0.80
ReadHeaderMethod · 0.80
EqualMethod · 0.80
DataMethod · 0.80
LenMethod · 0.80
WriteMethod · 0.45
ReadMethod · 0.45
TypeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…