diff options
author | Michael Muré <batolettre@gmail.com> | 2020-06-26 19:20:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-26 19:20:36 +0200 |
commit | 1e3dd82fd619f7b43b3193016232ef69f9707f42 (patch) | |
tree | 00e847500b34c6f9a721c71474993d1c08ae8fb1 /repository/mock_repo.go | |
parent | 2dd0dbb1344ae9293aae05346f977b5d5907934b (diff) | |
parent | 88ad7e606f1cbf9e47b968a208e3510f7f9a81c5 (diff) | |
download | git-bug-1e3dd82fd619f7b43b3193016232ef69f9707f42.tar.gz |
Merge pull request #411 from MichaelMure/repo-rework
Repository rework
Diffstat (limited to 'repository/mock_repo.go')
-rw-r--r-- | repository/mock_repo.go | 45 |
1 files changed, 12 insertions, 33 deletions
diff --git a/repository/mock_repo.go b/repository/mock_repo.go index 89d0f395..04d9355e 100644 --- a/repository/mock_repo.go +++ b/repository/mock_repo.go @@ -9,6 +9,7 @@ import ( ) var _ ClockedRepo = &mockRepoForTest{} +var _ TestedRepo = &mockRepoForTest{} // mockRepoForTest defines an instance of Repo that can be used for testing. type mockRepoForTest struct { @@ -18,8 +19,7 @@ type mockRepoForTest struct { trees map[git.Hash]string commits map[git.Hash]commit refs map[string]git.Hash - createClock lamport.Clock - editClock lamport.Clock + clocks map[string]lamport.Clock } type commit struct { @@ -35,8 +35,7 @@ func NewMockRepoForTest() *mockRepoForTest { trees: make(map[git.Hash]string), commits: make(map[git.Hash]commit), refs: make(map[string]git.Hash), - createClock: lamport.NewClock(), - editClock: lamport.NewClock(), + clocks: make(map[string]lamport.Clock), } } @@ -213,36 +212,16 @@ func (r *mockRepoForTest) GetTreeHash(commit git.Hash) (git.Hash, error) { panic("implement me") } -func (r *mockRepoForTest) LoadClocks() error { - return nil -} - -func (r *mockRepoForTest) WriteClocks() error { - return nil -} - -func (r *mockRepoForTest) CreateTime() lamport.Time { - return r.createClock.Time() -} - -func (r *mockRepoForTest) CreateTimeIncrement() (lamport.Time, error) { - return r.createClock.Increment(), nil -} - -func (r *mockRepoForTest) EditTime() lamport.Time { - return r.editClock.Time() -} - -func (r *mockRepoForTest) EditTimeIncrement() (lamport.Time, error) { - return r.editClock.Increment(), nil -} +func (r *mockRepoForTest) GetOrCreateClock(name string) (lamport.Clock, error) { + if c, ok := r.clocks[name]; ok { + return c, nil + } -func (r *mockRepoForTest) WitnessCreate(time lamport.Time) error { - r.createClock.Witness(time) - return nil + c := lamport.NewMemClock() + r.clocks[name] = c + return c, nil } -func (r *mockRepoForTest) WitnessEdit(time lamport.Time) error { - r.editClock.Witness(time) - return nil +func (r *mockRepoForTest) AddRemote(name string, url string) error { + panic("implement me") } |