diff options
author | Michael Muré <batolettre@gmail.com> | 2020-09-29 20:51:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-29 20:51:15 +0200 |
commit | 1204b66e0cc958c2ca3b328d25cbec347356a046 (patch) | |
tree | 852ba5a688eea6872b0885d23dc91342d09b468d /repository/git_testing.go | |
parent | 9f3a56b1f34a8b4a7a75357986e967afc4b96611 (diff) | |
parent | 4055495c8ba983033459507f3032ca93c6ec006a (diff) | |
download | git-bug-1204b66e0cc958c2ca3b328d25cbec347356a046.tar.gz git-bug-1204b66e0cc958c2ca3b328d25cbec347356a046.zip |
Merge pull request #412 from MichaelMure/gogit-repo
repository: go-git backed Repo
Diffstat (limited to 'repository/git_testing.go')
-rw-r--r-- | repository/git_testing.go | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/repository/git_testing.go b/repository/git_testing.go index 5ae4ccc9e..7d40bf1fd 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 +} |