aboutsummaryrefslogtreecommitdiffstats
path: root/repository/git_testing.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2021-04-09 13:01:14 +0200
committerMichael Muré <batolettre@gmail.com>2021-04-09 13:01:14 +0200
commit1520f678f7a2bc6e01d9b01df5ce49f2f46be7d7 (patch)
treef6d71c1f29cf06ccab9e4ae434b19ab17caa4385 /repository/git_testing.go
parent0fd570171d171aa574d7f01d6033a9c01d668465 (diff)
parentbc5f618eba812859bf87ce2c31b278bd518d4555 (diff)
downloadgit-bug-1520f678f7a2bc6e01d9b01df5ce49f2f46be7d7.tar.gz
Merge remote-tracking branch 'origin/master' into dev-gh-bridge
Diffstat (limited to 'repository/git_testing.go')
-rw-r--r--repository/git_testing.go72
1 files changed, 0 insertions, 72 deletions
diff --git a/repository/git_testing.go b/repository/git_testing.go
deleted file mode 100644
index 2168d53e..00000000
--- a/repository/git_testing.go
+++ /dev/null
@@ -1,72 +0,0 @@
-package repository
-
-import (
- "io/ioutil"
- "log"
-
- "github.com/99designs/keyring"
-)
-
-// This is intended for testing only
-
-func CreateTestRepo(bare bool) TestedRepo {
- dir, err := ioutil.TempDir("", "")
- if err != nil {
- log.Fatal(err)
- }
-
- var creator func(string) (*GitRepo, error)
-
- if bare {
- creator = InitBareGitRepo
- } else {
- creator = InitGitRepo
- }
-
- repo, err := creator(dir)
- if err != nil {
- log.Fatal(err)
- }
-
- config := repo.LocalConfig()
- if err := config.StoreString("user.name", "testuser"); err != nil {
- log.Fatal("failed to set user.name for test repository: ", err)
- }
- if err := config.StoreString("user.email", "testuser@example.com"); err != nil {
- log.Fatal("failed to set user.email for test repository: ", err)
- }
-
- // make sure we use a mock keyring for testing to not interact with the global system
- return &replaceKeyring{
- TestedRepo: repo,
- keyring: keyring.NewArrayKeyring(nil),
- }
-}
-
-func SetupReposAndRemote() (repoA, repoB, remote TestedRepo) {
- repoA = CreateGoGitTestRepo(false)
- repoB = CreateGoGitTestRepo(false)
- remote = CreateGoGitTestRepo(true)
-
- err := repoA.AddRemote("origin", remote.GetLocalRemote())
- if err != nil {
- log.Fatal(err)
- }
-
- err = repoB.AddRemote("origin", remote.GetLocalRemote())
- if err != nil {
- log.Fatal(err)
- }
-
- return repoA, repoB, remote
-}
-
-// replaceKeyring allow to replace the Keyring of the underlying repo
-type replaceKeyring struct {
- TestedRepo
- keyring Keyring
-}
-
-func (rk replaceKeyring) Keyring() Keyring {
- return rk.keyring
-}