aboutsummaryrefslogtreecommitdiffstats
path: root/repository/mock_repo.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-07-13 21:21:24 +0200
committerMichael Muré <batolettre@gmail.com>2018-07-13 21:21:24 +0200
commit1779a0f3b92d58654b43444addeaf437a64d77a8 (patch)
tree9f973413454894f0456d7379425070d468712242 /repository/mock_repo.go
parent289f8d53ee960d35c1f0c42e8753ad536737b875 (diff)
downloadgit-bug-1779a0f3b92d58654b43444addeaf437a64d77a8.tar.gz
serialize a Bug to git as a blob+tree+commit+ref
Diffstat (limited to 'repository/mock_repo.go')
-rw-r--r--repository/mock_repo.go53
1 files changed, 40 insertions, 13 deletions
diff --git a/repository/mock_repo.go b/repository/mock_repo.go
index f5d27d12..e747eb24 100644
--- a/repository/mock_repo.go
+++ b/repository/mock_repo.go
@@ -1,33 +1,60 @@
package repository
import (
- "crypto/sha1"
- "encoding/json"
- "fmt"
+ "github.com/MichaelMure/git-bug/util"
)
// mockRepoForTest defines an instance of Repo that can be used for testing.
type mockRepoForTest struct{}
+func NewMockRepoForTest() Repo {
+ return &mockRepoForTest{}
+}
+
// GetPath returns the path to the repo.
-func (r *mockRepoForTest) GetPath() string { return "~/mockRepo/" }
+func (r *mockRepoForTest) GetPath() string {
+ return "~/mockRepo/"
+}
-// GetRepoStateHash returns a hash which embodies the entire current state of a repository.
-func (r *mockRepoForTest) GetRepoStateHash() (string, error) {
- repoJSON, err := json.Marshal(r)
- if err != nil {
- return "", err
- }
- return fmt.Sprintf("%x", sha1.Sum([]byte(repoJSON))), nil
+func (r *mockRepoForTest) GetUserName() (string, error) {
+ return "René Descartes", nil
}
// GetUserEmail returns the email address that the user has used to configure git.
-func (r *mockRepoForTest) GetUserEmail() (string, error) { return "user@example.com", nil }
+func (r *mockRepoForTest) GetUserEmail() (string, error) {
+ return "user@example.com", nil
+}
// GetCoreEditor returns the name of the editor that the user has used to configure git.
-func (r *mockRepoForTest) GetCoreEditor() (string, error) { return "vi", nil }
+func (r *mockRepoForTest) GetCoreEditor() (string, error) {
+ return "vi", nil
+}
// PushRefs push git refs to a remote
func (r *mockRepoForTest) PushRefs(remote string, refPattern string) error {
return nil
}
+
+func (r *mockRepoForTest) PullRefs(remote string, refPattern string) error {
+ return nil
+}
+
+func (r *mockRepoForTest) StoreData([]byte) (util.Hash, error) {
+ return "", nil
+}
+
+func (r *mockRepoForTest) StoreTree(mapping map[string]util.Hash) (util.Hash, error) {
+ return "", nil
+}
+
+func (r *mockRepoForTest) StoreCommit(treeHash util.Hash) (util.Hash, error) {
+ return "", nil
+}
+
+func (r *mockRepoForTest) StoreCommitWithParent(treeHash util.Hash, parent util.Hash) (util.Hash, error) {
+ return "", nil
+}
+
+func (r *mockRepoForTest) UpdateRef(ref string, hash util.Hash) error {
+ return nil
+}