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

Function TestIndexAddAndWriteTreeTo

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

Source from the content-addressed store, hash-verified

91}
92
93func TestIndexAddAndWriteTreeTo(t *testing.T) {
94 t.Parallel()
95 repo := createTestRepo(t)
96 defer cleanupTestRepo(t, repo)
97
98 odb, err := repo.Odb()
99 checkFatal(t, err)
100
101 blobID, err := odb.Write([]byte("foo\n"), ObjectBlob)
102 checkFatal(t, err)
103
104 idx, err := NewIndex()
105 checkFatal(t, err)
106
107 if idx.Path() != "" {
108 t.Fatal("in-memory repo has a path")
109 }
110
111 entry := IndexEntry{
112 Path: "README",
113 Id: blobID,
114 Mode: FilemodeBlob,
115 }
116
117 err = idx.Add(&entry)
118 checkFatal(t, err)
119
120 treeId, err := idx.WriteTreeTo(repo)
121 checkFatal(t, err)
122
123 if treeId.String() != "b7119b11e8ef7a1a5a34d3ac87f5b075228ac81e" {
124 t.Fatalf("%v", treeId.String())
125 }
126}
127
128func TestIndexRemoveDirectory(t *testing.T) {
129 repo := createTestRepo(t)

Callers

nothing calls this directly

Calls 10

PathMethod · 0.95
AddMethod · 0.95
WriteTreeToMethod · 0.95
createTestRepoFunction · 0.85
cleanupTestRepoFunction · 0.85
checkFatalFunction · 0.85
NewIndexFunction · 0.85
OdbMethod · 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…