aboutsummaryrefslogtreecommitdiffstats
path: root/repository/mock_repo.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-07-12 09:55:13 +0200
committerMichael Muré <batolettre@gmail.com>2018-07-12 09:55:13 +0200
commitd0443659123f912e9385e27efebe4b7da65aa2f6 (patch)
tree090a36d2618ecff259cbcabd501d33d460d1cd7a /repository/mock_repo.go
parenta85730cf5287d40a1e32d3a671ba2296c73387cb (diff)
downloadgit-bug-d0443659123f912e9385e27efebe4b7da65aa2f6.tar.gz
more experiment
Diffstat (limited to 'repository/mock_repo.go')
-rw-r--r--repository/mock_repo.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/repository/mock_repo.go b/repository/mock_repo.go
new file mode 100644
index 00000000..8587d0da
--- /dev/null
+++ b/repository/mock_repo.go
@@ -0,0 +1,33 @@
+package repository
+
+import (
+ "crypto/sha1"
+ "encoding/json"
+ "fmt"
+)
+
+// mockRepoForTest defines an instance of Repo that can be used for testing.
+type mockRepoForTest struct {}
+
+// GetPath returns the path to the repo.
+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
+}
+
+// GetUserEmail returns the email address that the user has used to configure git.
+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 }
+
+// PushRefs push git refs to a remote
+func (r *mockRepoForTest) PushRefs(remote string, refPattern string) error {
+ return nil
+} \ No newline at end of file