aboutsummaryrefslogtreecommitdiffstats
path: root/repository/mock_repo.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-08-06 20:31:20 +0200
committerMichael Muré <batolettre@gmail.com>2018-08-06 20:31:20 +0200
commit435be2b693aee89ed34a2d1e7291b3b141b19717 (patch)
tree89244a9dcb995c27002995e9f25f9be631101713 /repository/mock_repo.go
parent593891b8e01fd89866b30854a60aece1dad5f6ab (diff)
downloadgit-bug-435be2b693aee89ed34a2d1e7291b3b141b19717.tar.gz
bug: add a Lamport logical clock to be able to sort bugs by creation time and edit time without having to rely on a timestamp
Diffstat (limited to 'repository/mock_repo.go')
-rw-r--r--repository/mock_repo.go46
1 files changed, 38 insertions, 8 deletions
diff --git a/repository/mock_repo.go b/repository/mock_repo.go
index f8653c64..eb48f85f 100644
--- a/repository/mock_repo.go
+++ b/repository/mock_repo.go
@@ -10,10 +10,12 @@ import (
// mockRepoForTest defines an instance of Repo that can be used for testing.
type mockRepoForTest struct {
- blobs map[util.Hash][]byte
- trees map[util.Hash]string
- commits map[util.Hash]commit
- refs map[string]util.Hash
+ blobs map[util.Hash][]byte
+ trees map[util.Hash]string
+ commits map[util.Hash]commit
+ refs map[string]util.Hash
+ createClock util.LamportClock
+ editClock util.LamportClock
}
type commit struct {
@@ -23,10 +25,12 @@ type commit struct {
func NewMockRepoForTest() Repo {
return &mockRepoForTest{
- blobs: make(map[util.Hash][]byte),
- trees: make(map[util.Hash]string),
- commits: make(map[util.Hash]commit),
- refs: make(map[string]util.Hash),
+ blobs: make(map[util.Hash][]byte),
+ trees: make(map[util.Hash]string),
+ commits: make(map[util.Hash]commit),
+ refs: make(map[string]util.Hash),
+ createClock: util.NewLamportClock(),
+ editClock: util.NewLamportClock(),
}
}
@@ -200,3 +204,29 @@ func (r *mockRepoForTest) FindCommonAncestor(hash1 util.Hash, hash2 util.Hash) (
func (r *mockRepoForTest) GetTreeHash(commit util.Hash) (util.Hash, error) {
panic("implement me")
}
+
+func (r *mockRepoForTest) LoadClocks() error {
+ return nil
+}
+
+func (r *mockRepoForTest) WriteClocks() error {
+ return nil
+}
+
+func (r *mockRepoForTest) CreateTimeIncrement() (util.LamportTime, error) {
+ return r.createClock.Increment(), nil
+}
+
+func (r *mockRepoForTest) EditTimeIncrement() (util.LamportTime, error) {
+ return r.editClock.Increment(), nil
+}
+
+func (r *mockRepoForTest) CreateWitness(time util.LamportTime) error {
+ r.createClock.Witness(time)
+ return nil
+}
+
+func (r *mockRepoForTest) EditWitness(time util.LamportTime) error {
+ r.editClock.Witness(time)
+ return nil
+}