2015-07-21 13:12:19 +00:00
|
|
|
// Copyright (C) 2015 The Protocol Authors.
|
|
|
|
|
|
|
|
package protocol
|
|
|
|
|
|
|
|
import "testing"
|
|
|
|
|
|
|
|
func TestWinsConflict(t *testing.T) {
|
|
|
|
testcases := [][2]FileInfo{
|
|
|
|
// The first should always win over the second
|
2016-08-06 13:05:59 +00:00
|
|
|
{{ModifiedS: 42}, {ModifiedS: 41}},
|
|
|
|
{{ModifiedS: 41}, {ModifiedS: 42, Deleted: true}},
|
2018-06-24 07:50:18 +00:00
|
|
|
{{Deleted: true}, {ModifiedS: 10, RawInvalid: true}},
|
2018-12-18 11:36:38 +00:00
|
|
|
{{ModifiedS: 41, Version: Vector{Counters: []Counter{{ID: 42, Value: 2}, {ID: 43, Value: 1}}}}, {ModifiedS: 41, Version: Vector{Counters: []Counter{{ID: 42, Value: 1}, {ID: 43, Value: 2}}}}},
|
2015-07-21 13:12:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for _, tc := range testcases {
|
2020-05-30 07:50:23 +00:00
|
|
|
if !WinsConflict(tc[0], tc[1]) {
|
2015-07-21 13:12:19 +00:00
|
|
|
t.Errorf("%v should win over %v", tc[0], tc[1])
|
|
|
|
}
|
2020-05-30 07:50:23 +00:00
|
|
|
if WinsConflict(tc[1], tc[0]) {
|
2015-07-21 13:12:19 +00:00
|
|
|
t.Errorf("%v should not win over %v", tc[1], tc[0])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|