mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-23 03:18:59 +00:00
944ddcf768
* go mod init; rm -rf vendor * tweak proto files and generation * go mod vendor * clean up build.go * protobuf literals in tests * downgrade gogo/protobuf
25 lines
760 B
Go
25 lines
760 B
Go
// 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
|
|
{{ModifiedS: 42}, {ModifiedS: 41}},
|
|
{{ModifiedS: 41}, {ModifiedS: 42, Deleted: true}},
|
|
{{Deleted: true}, {ModifiedS: 10, RawInvalid: true}},
|
|
{{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}}}}},
|
|
}
|
|
|
|
for _, tc := range testcases {
|
|
if !tc[0].WinsConflict(tc[1]) {
|
|
t.Errorf("%v should win over %v", tc[0], tc[1])
|
|
}
|
|
if tc[1].WinsConflict(tc[0]) {
|
|
t.Errorf("%v should not win over %v", tc[1], tc[0])
|
|
}
|
|
}
|
|
}
|