diff options
author | Jakob Borg <jakob@nym.se> | 2014-04-09 10:24:43 +0200 |
---|---|---|
committer | Jakob Borg <jakob@nym.se> | 2014-04-09 10:24:43 +0200 |
commit | 346b6f4f1196d31078714ca8299d7899fc422421 (patch) | |
tree | fb9dcbfd0103b6aae6e88a2bf87674499a0eb35a | |
parent | 07eb4020bd5b2bd8c161ab937e04ab6bde466f7d (diff) |
Ensure deterministic test outcome
-rw-r--r-- | files/set_test.go | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/files/set_test.go b/files/set_test.go index d28baca8bf..fe3339d349 100644 --- a/files/set_test.go +++ b/files/set_test.go @@ -82,10 +82,24 @@ func TestLocalDeleted(t *testing.T) { m.ReplaceWithDelete(cid.LocalID, local1) - local2 := []scanner.File{ + m.ReplaceWithDelete(cid.LocalID, []scanner.File{ local1[0], + // [1] removed local1[2], - } + local1[3], + local1[4], + }) + m.ReplaceWithDelete(cid.LocalID, []scanner.File{ + local1[0], + local1[2], + // [3] removed + local1[4], + }) + m.ReplaceWithDelete(cid.LocalID, []scanner.File{ + local1[0], + local1[2], + // [4] removed + }) expectedGlobal1 := []scanner.File{ local1[0], @@ -95,7 +109,6 @@ func TestLocalDeleted(t *testing.T) { scanner.File{Name: "z", Version: 1003, Flags: protocol.FlagDeleted | protocol.FlagDirectory}, } - m.ReplaceWithDelete(cid.LocalID, local2) g := m.Global() sort.Sort(fileList(g)) sort.Sort(fileList(expectedGlobal1)) @@ -104,9 +117,10 @@ func TestLocalDeleted(t *testing.T) { t.Errorf("Global incorrect;\n A: %v !=\n E: %v", g, expectedGlobal1) } - local3 := []scanner.File{ + m.ReplaceWithDelete(cid.LocalID, []scanner.File{ local1[0], - } + // [2] removed + }) expectedGlobal2 := []scanner.File{ local1[0], @@ -116,7 +130,6 @@ func TestLocalDeleted(t *testing.T) { scanner.File{Name: "z", Version: 1003, Flags: protocol.FlagDeleted | protocol.FlagDirectory}, } - m.ReplaceWithDelete(cid.LocalID, local3) g = m.Global() sort.Sort(fileList(g)) sort.Sort(fileList(expectedGlobal2)) @@ -284,6 +297,10 @@ func TestNeed(t *testing.T) { m.Replace(1, remote) need := m.Need(0) + + sort.Sort(fileList(need)) + sort.Sort(fileList(shouldNeed)) + if !reflect.DeepEqual(need, shouldNeed) { t.Errorf("Need incorrect;\n%v !=\n%v", need, shouldNeed) } |