Преглед изворни кода

storage: fix missing continue in keyIndex.since

It should continue to skip following operations.

The test from rev14 to rev0 fails if it doesn't call continue and append
all revisions of the same main rev to the list.
Yicheng Qin пре 11 година
родитељ
комит
87b5143b15
2 измењених фајлова са 16 додато и 0 уклоњено
  1. 1 0
      storage/key_index.go
  2. 15 0
      storage/key_index_test.go

+ 1 - 0
storage/key_index.go

@@ -177,6 +177,7 @@ func (ki *keyIndex) since(rev int64) []revision {
 				// replace the revision with a new one that has higher sub value,
 				// because the original one should not be seen by external
 				revs[len(revs)-1] = r
+				continue
 			}
 			revs = append(revs, r)
 			last = r.main

+ 15 - 0
storage/key_index_test.go

@@ -97,6 +97,21 @@ func TestKeyIndexSince(t *testing.T) {
 		{17, nil},
 		{16, allRevs[6:]},
 		{15, allRevs[6:]},
+		{14, allRevs[5:]},
+		{13, allRevs[5:]},
+		{12, allRevs[4:]},
+		{11, allRevs[4:]},
+		{10, allRevs[3:]},
+		{9, allRevs[3:]},
+		{8, allRevs[2:]},
+		{7, allRevs[2:]},
+		{6, allRevs[1:]},
+		{5, allRevs[1:]},
+		{4, allRevs},
+		{3, allRevs},
+		{2, allRevs},
+		{1, allRevs},
+		{0, allRevs},
 	}
 
 	for i, tt := range tests {