1package repository
2
3import (
4 "crypto/sha1"
5 "encoding/json"
6 "fmt"
7)
8
9// mockRepoForTest defines an instance of Repo that can be used for testing.
10type mockRepoForTest struct {}
11
12// GetPath returns the path to the repo.
13func (r *mockRepoForTest) GetPath() string { return "~/mockRepo/" }
14
15// GetRepoStateHash returns a hash which embodies the entire current state of a repository.
16func (r *mockRepoForTest) GetRepoStateHash() (string, error) {
17 repoJSON, err := json.Marshal(r)
18 if err != nil {
19 return "", err
20 }
21 return fmt.Sprintf("%x", sha1.Sum([]byte(repoJSON))), nil
22}
23
24// GetUserEmail returns the email address that the user has used to configure git.
25func (r *mockRepoForTest) GetUserEmail() (string, error) { return "user@example.com", nil }
26
27// GetCoreEditor returns the name of the editor that the user has used to configure git.
28func (r *mockRepoForTest) GetCoreEditor() (string, error) { return "vi", nil }
29
30// PushRefs push git refs to a remote
31func (r *mockRepoForTest) PushRefs(remote string, refPattern string) error {
32 return nil
33}