MCPcopy Create free account
hub / github.com/git-bug/git-bug / CreateGoGitTestRepo

Function CreateGoGitTestRepo

repository/gogit_testing.go:16–54  ·  view source on GitHub ↗

This is intended for testing only

(t testing.TB, bare bool)

Source from the content-addressed store, hash-verified

14// This is intended for testing only
15
16func CreateGoGitTestRepo(t testing.TB, bare bool) TestedRepo {
17 t.Helper()
18
19 dir := t.TempDir()
20
21 var creator func(string, string) (*GoGitRepo, error)
22
23 if bare {
24 creator = InitBareGoGitRepo
25 } else {
26 creator = InitGoGitRepo
27 }
28
29 repo, err := creator(dir, namespace)
30 if err != nil {
31 log.Fatal(err)
32 }
33
34 t.Cleanup(func() {
35 err := repo.Close()
36 if err != nil {
37 log.Println(err)
38 }
39 })
40
41 config := repo.LocalConfig()
42 if err := config.StoreString("user.name", "testuser"); err != nil {
43 log.Fatal("failed to set user.name for test repository: ", err)
44 }
45 if err := config.StoreString("user.email", "testuser@example.com"); err != nil {
46 log.Fatal("failed to set user.email for test repository: ", err)
47 }
48
49 // make sure we use a mock keyring for testing to not interact with the global system
50 return &replaceKeyring{
51 TestedRepo: repo,
52 keyring: keyring.NewArrayKeyring(nil),
53 }
54}
55
56func SetupGoGitReposAndRemote(t *testing.T) (repoA, repoB, remote TestedRepo) {
57 t.Helper()

Callers 15

TestCacheFunction · 0.92
TestRemoveFunction · 0.92
TestCacheEvictionFunction · 0.92
TestLongDescriptionFunction · 0.92
TestGithubImporterFunction · 0.92
TestGithubPushPullFunction · 0.92
TestGitlabImportFunction · 0.92
TestGitlabPushPullFunction · 0.92
newTestEnvFunction · 0.92
TestSelectFunction · 0.92
TestIdentityRemoveFunction · 0.92

Calls 6

HelperMethod · 0.80
FatalMethod · 0.80
CloseMethod · 0.65
PrintlnMethod · 0.65
LocalConfigMethod · 0.65
StoreStringMethod · 0.65

Tested by 15

TestCacheFunction · 0.74
TestRemoveFunction · 0.74
TestCacheEvictionFunction · 0.74
TestLongDescriptionFunction · 0.74
TestGithubImporterFunction · 0.74
TestGithubPushPullFunction · 0.74
TestGitlabImportFunction · 0.74
TestGitlabPushPullFunction · 0.74
TestSelectFunction · 0.74
TestIdentityRemoveFunction · 0.74
TestIDFunction · 0.74