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

Function TestRepositorySetConfig

repository_test.go:98–148  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

96}
97
98func TestRepositorySetConfig(t *testing.T) {
99 repo := createTestRepo(t)
100 defer cleanupTestRepo(t, repo)
101
102 loc, err := time.LoadLocation("Europe/Berlin")
103 checkFatal(t, err)
104 sig := &Signature{
105 Name: "Rand Om Hacker",
106 Email: "random@hacker.com",
107 When: time.Date(2013, 03, 06, 14, 30, 0, 0, loc),
108 }
109
110 idx, err := repo.Index()
111 checkFatal(t, err)
112 err = idx.AddByPath("README")
113
114 treeId, err := idx.WriteTree()
115 checkFatal(t, err)
116
117 message := "This is a commit\n"
118 tree, err := repo.LookupTree(treeId)
119 checkFatal(t, err)
120 _, err = repo.CreateCommit("HEAD", sig, sig, message, tree)
121 checkFatal(t, err)
122
123 repoConfig, err := repo.Config()
124 checkFatal(t, err)
125
126 temp := Config{}
127 localConfig, err := temp.OpenLevel(repoConfig, ConfigLevelLocal)
128 checkFatal(t, err)
129 repoConfig = nil
130
131 err = repo.SetConfig(localConfig)
132 checkFatal(t, err)
133
134 configFieldName := "core.filemode"
135 err = localConfig.SetBool(configFieldName, true)
136 checkFatal(t, err)
137
138 localConfig = nil
139
140 repoConfig, err = repo.Config()
141 checkFatal(t, err)
142
143 result, err := repoConfig.LookupBool(configFieldName)
144 checkFatal(t, err)
145 if result != true {
146 t.Fatal("result must be true")
147 }
148}
149
150func TestRepositoryItemPath(t *testing.T) {
151 repo := createTestRepo(t)

Callers

nothing calls this directly

Calls 13

OpenLevelMethod · 0.95
createTestRepoFunction · 0.85
cleanupTestRepoFunction · 0.85
checkFatalFunction · 0.85
AddByPathMethod · 0.80
WriteTreeMethod · 0.80
LookupTreeMethod · 0.80
CreateCommitMethod · 0.80
ConfigMethod · 0.80
SetConfigMethod · 0.80
SetBoolMethod · 0.80
LookupBoolMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…