@@ -792,17 +792,6 @@ func TestRequestRemoteRenameChanged(t *testing.T) {
792
792
fc .sendIndexUpdate ()
793
793
select {
794
794
case <- done :
795
- done = make (chan struct {})
796
- fc .mut .Lock ()
797
- fc .indexFn = func (folder string , fs []protocol.FileInfo ) {
798
- select {
799
- case <- done :
800
- t .Fatalf ("More than one index update sent" )
801
- default :
802
- }
803
- close (done )
804
- }
805
- fc .mut .Unlock ()
806
795
case <- time .After (10 * time .Second ):
807
796
t .Fatal ("timed out" )
808
797
}
@@ -813,6 +802,42 @@ func TestRequestRemoteRenameChanged(t *testing.T) {
813
802
}
814
803
}
815
804
805
+ var gotA , gotB , gotConfl bool
806
+ done = make (chan struct {})
807
+ fc .mut .Lock ()
808
+ fc .indexFn = func (folder string , fs []protocol.FileInfo ) {
809
+ select {
810
+ case <- done :
811
+ t .Fatalf ("Received more index updates than expected" )
812
+ default :
813
+ }
814
+ for _ , f := range fs {
815
+ switch {
816
+ case f .Name == a :
817
+ if gotA {
818
+ t .Error ("Got more than one index update for" , f .Name )
819
+ }
820
+ gotA = true
821
+ case f .Name == b :
822
+ if gotB {
823
+ t .Error ("Got more than one index update for" , f .Name )
824
+ }
825
+ gotB = true
826
+ case strings .HasPrefix (f .Name , "b.sync-conflict-" ):
827
+ if gotConfl {
828
+ t .Error ("Got more than one index update for conflicts of" , f .Name )
829
+ }
830
+ gotConfl = true
831
+ default :
832
+ t .Error ("Got unexpected file in index update" , f .Name )
833
+ }
834
+ }
835
+ if gotA && gotB && gotConfl {
836
+ close (done )
837
+ }
838
+ }
839
+ fc .mut .Unlock ()
840
+
816
841
fd , err := tfs .OpenFile (b , fs .OptReadWrite , 0644 )
817
842
if err != nil {
818
843
t .Fatal (err )
@@ -826,11 +851,20 @@ func TestRequestRemoteRenameChanged(t *testing.T) {
826
851
// rename
827
852
fc .deleteFile (a )
828
853
fc .updateFile (b , 0644 , protocol .FileInfoTypeFile , data [a ])
854
+ // Make sure the remote file for b is newer and thus stays global -> local conflict
855
+ fc .mut .Lock ()
856
+ for i := range fc .files {
857
+ if fc .files [i ].Name == b {
858
+ fc .files [i ].ModifiedS += 100
859
+ break
860
+ }
861
+ }
862
+ fc .mut .Unlock ()
829
863
fc .sendIndexUpdate ()
830
864
select {
831
865
case <- done :
832
866
case <- time .After (10 * time .Second ):
833
- t .Fatal ("timed out" )
867
+ t .Errorf ("timed out without receiving all expected index updates " )
834
868
}
835
869
836
870
// Check outcome
@@ -839,9 +873,16 @@ func TestRequestRemoteRenameChanged(t *testing.T) {
839
873
case path == a :
840
874
t .Errorf (`File "a" was not removed` )
841
875
case path == b :
842
- if err := equalContents (filepath .Join (tmpDir , b ), otherData ); err != nil {
843
- t .Errorf (`Modified file "b" was overwritten` )
876
+ if err := equalContents (filepath .Join (tmpDir , b ), data [a ]); err != nil {
877
+ t .Error (`File "b" has unexpected content (renamed from a on remote)` )
878
+ }
879
+ case strings .HasPrefix (path , b + ".sync-conflict-" ):
880
+ if err := equalContents (filepath .Join (tmpDir , path ), otherData ); err != nil {
881
+ t .Error (`Sync conflict of "b" has unexptected content` )
844
882
}
883
+ case path == "." || strings .HasPrefix (path , ".stfolder" ):
884
+ default :
885
+ t .Error ("Found unexpected file" , path )
845
886
}
846
887
return nil
847
888
})
0 commit comments