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

Function TestIndexWriteTreeTo

index_test.go:58–91  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

56}
57
58func TestIndexWriteTreeTo(t *testing.T) {
59 t.Parallel()
60 repo := createTestRepo(t)
61 defer cleanupTestRepo(t, repo)
62
63 idx, err := NewIndex()
64 checkFatal(t, err)
65
66 odb, err := repo.Odb()
67 checkFatal(t, err)
68
69 content, err := ioutil.ReadFile(path.Join(repo.Workdir(), "README"))
70 checkFatal(t, err)
71
72 id, err := odb.Write(content, ObjectBlob)
73 checkFatal(t, err)
74
75 err = idx.Add(&IndexEntry{
76 Mode: FilemodeBlob,
77 Uid: 0,
78 Gid: 0,
79 Size: uint32(len(content)),
80 Id: id,
81 Path: "README",
82 })
83 checkFatal(t, err)
84
85 treeId, err := idx.WriteTreeTo(repo)
86 checkFatal(t, err)
87
88 if treeId.String() != "b7119b11e8ef7a1a5a34d3ac87f5b075228ac81e" {
89 t.Fatalf("%v", treeId.String())
90 }
91}
92
93func TestIndexAddAndWriteTreeTo(t *testing.T) {
94 t.Parallel()

Callers

nothing calls this directly

Calls 10

AddMethod · 0.95
WriteTreeToMethod · 0.95
createTestRepoFunction · 0.85
cleanupTestRepoFunction · 0.85
NewIndexFunction · 0.85
checkFatalFunction · 0.85
OdbMethod · 0.80
WorkdirMethod · 0.80
WriteMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…