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

Function TestOdbStream

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

Source from the content-addressed store, hash-verified

55}
56
57func TestOdbStream(t *testing.T) {
58 t.Parallel()
59 repo := createTestRepo(t)
60 defer cleanupTestRepo(t, repo)
61
62 _, _ = seedTestRepo(t, repo)
63
64 odb, err := repo.Odb()
65 checkFatal(t, err)
66
67 str := "hello, world!"
68
69 writeStream, err := odb.NewWriteStream(int64(len(str)), ObjectBlob)
70 checkFatal(t, err)
71 n, err := io.WriteString(writeStream, str)
72 checkFatal(t, err)
73 if n != len(str) {
74 t.Fatalf("Bad write length %v != %v", n, len(str))
75 }
76
77 err = writeStream.Close()
78 checkFatal(t, err)
79
80 expectedId, err := NewOid("30f51a3fba5274d53522d0f19748456974647b4f")
81 checkFatal(t, err)
82 if writeStream.Id.Cmp(expectedId) != 0 {
83 t.Fatal("Wrong data written")
84 }
85
86 readStream, err := odb.NewReadStream(&writeStream.Id)
87 checkFatal(t, err)
88 data, err := ioutil.ReadAll(readStream)
89 if str != string(data) {
90 t.Fatalf("Wrong data read %v != %v", str, string(data))
91 }
92}
93
94func TestOdbHash(t *testing.T) {
95 t.Parallel()

Callers

nothing calls this directly

Calls 10

createTestRepoFunction · 0.85
cleanupTestRepoFunction · 0.85
seedTestRepoFunction · 0.85
checkFatalFunction · 0.85
NewOidFunction · 0.85
OdbMethod · 0.80
NewWriteStreamMethod · 0.80
NewReadStreamMethod · 0.80
CloseMethod · 0.65
CmpMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…