mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-23 03:18:59 +00:00
ea87bcefd6
This adds a new nanoseconds field to the FileInfo, populates it during scans and sets the non-truncated time in Chtimes calls. The actual file modification time is defined as modified_s seconds + modified_ns nanoseconds. It's expected that the modified_ns field is <= 1e9 (that is, all whole seconds should go in the modified_s field) but not really enforced. Given that it's an int32 the timestamp can be adjusted += ~2.9 seconds by the modified_ns field... GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3431
24 lines
640 B
Go
24 lines
640 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}},
|
|
{{ModifiedS: 41, Version: Vector{[]Counter{{42, 2}, {43, 1}}}}, {ModifiedS: 41, Version: Vector{[]Counter{{42, 1}, {43, 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])
|
|
}
|
|
}
|
|
}
|