conflict_test.go 617 B

1234567891011121314151617181920212223
  1. // Copyright (C) 2015 The Protocol Authors.
  2. package protocol
  3. import "testing"
  4. func TestWinsConflict(t *testing.T) {
  5. testcases := [][2]FileInfo{
  6. // The first should always win over the second
  7. {{Modified: 42}, {Modified: 41}},
  8. {{Modified: 41}, {Modified: 42, Flags: FlagDeleted}},
  9. {{Modified: 41, Version: Vector{{42, 2}, {43, 1}}}, {Modified: 41, Version: Vector{{42, 1}, {43, 2}}}},
  10. }
  11. for _, tc := range testcases {
  12. if !tc[0].WinsConflict(tc[1]) {
  13. t.Errorf("%v should win over %v", tc[0], tc[1])
  14. }
  15. if tc[1].WinsConflict(tc[0]) {
  16. t.Errorf("%v should not win over %v", tc[1], tc[0])
  17. }
  18. }
  19. }