aboutsummaryrefslogtreecommitdiffstats
path: root/repository/mock_repo.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2020-12-01 21:19:23 +0100
committerMichael Muré <batolettre@gmail.com>2020-12-05 21:41:10 +0100
commitbca9ae82745ffd619fd321f4200016c184849f94 (patch)
tree6223d23c3e865bd2d29ea888d944a57467f2b44d /repository/mock_repo.go
parent28adf41af6a5c0f4b19875912d056b03ea6710f8 (diff)
downloadgit-bug-bca9ae82745ffd619fd321f4200016c184849f94.tar.gz
repo: more work towards RepoStorage
Diffstat (limited to 'repository/mock_repo.go')
-rw-r--r--repository/mock_repo.go32
1 files changed, 27 insertions, 5 deletions
diff --git a/repository/mock_repo.go b/repository/mock_repo.go
index 628939aa..74d4cae7 100644
--- a/repository/mock_repo.go
+++ b/repository/mock_repo.go
@@ -6,6 +6,8 @@ import (
"strings"
"github.com/99designs/keyring"
+ "github.com/go-git/go-billy/v5"
+ "github.com/go-git/go-billy/v5/memfs"
"github.com/MichaelMure/git-bug/util/lamport"
)
@@ -18,6 +20,7 @@ type mockRepoForTest struct {
*mockRepoConfig
*mockRepoKeyring
*mockRepoCommon
+ *mockRepoStorage
*mockRepoData
*mockRepoClock
}
@@ -27,6 +30,7 @@ func NewMockRepoForTest() *mockRepoForTest {
mockRepoConfig: NewMockRepoConfig(),
mockRepoKeyring: NewMockRepoKeyring(),
mockRepoCommon: NewMockRepoCommon(),
+ mockRepoStorage: NewMockRepoStorage(),
mockRepoData: NewMockRepoData(),
mockRepoClock: NewMockRepoClock(),
}
@@ -86,11 +90,6 @@ func NewMockRepoCommon() *mockRepoCommon {
return &mockRepoCommon{}
}
-// GetPath returns the path to the repo.
-func (r *mockRepoCommon) GetPath() string {
- return "~/mockRepo/"
-}
-
func (r *mockRepoCommon) GetUserName() (string, error) {
return "René Descartes", nil
}
@@ -112,6 +111,20 @@ func (r *mockRepoCommon) GetRemotes() (map[string]string, error) {
}, nil
}
+var _ RepoStorage = &mockRepoStorage{}
+
+type mockRepoStorage struct {
+ localFs billy.Filesystem
+}
+
+func NewMockRepoStorage() *mockRepoStorage {
+ return &mockRepoStorage{localFs: memfs.New()}
+}
+
+func (m *mockRepoStorage) LocalStorage() billy.Filesystem {
+ return m.localFs
+}
+
var _ RepoData = &mockRepoData{}
type commit struct {
@@ -314,6 +327,15 @@ func (r *mockRepoData) AddRemote(name string, url string) error {
panic("implement me")
}
+func (m mockRepoForTest) GetLocalRemote() string {
+ panic("implement me")
+}
+
+func (m mockRepoForTest) EraseFromDisk() error {
+ // nothing to do
+ return nil
+}
+
type mockRepoClock struct {
clocks map[string]lamport.Clock
}