aboutsummaryrefslogtreecommitdiffstats
path: root/repository/git_testing.go
diff options
context:
space:
mode:
Diffstat (limited to 'repository/git_testing.go')
-rw-r--r--repository/git_testing.go18
1 files changed, 17 insertions, 1 deletions
diff --git a/repository/git_testing.go b/repository/git_testing.go
index 5ae4ccc9..7d40bf1f 100644
--- a/repository/git_testing.go
+++ b/repository/git_testing.go
@@ -3,6 +3,8 @@ package repository
import (
"io/ioutil"
"log"
+
+ "github.com/99designs/keyring"
)
// This is intended for testing only
@@ -34,7 +36,11 @@ func CreateTestRepo(bare bool) TestedRepo {
log.Fatal("failed to set user.email for test repository: ", err)
}
- return repo
+ // 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) {
@@ -56,3 +62,13 @@ func SetupReposAndRemote() (repoA, repoB, remote TestedRepo) {
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
+}