This repository has been archived by the owner on Dec 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcore_test.go
1565 lines (1471 loc) · 116 KB
/
core_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package main
import (
"errors"
"flag"
"io"
"log"
"os"
"runtime"
"testing"
"github.com/gotk3/gotk3/gtk"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestMain(m *testing.M) {
// Silence debug logging unless running under -v.
flag.Parse()
if !testing.Verbose() {
log.SetOutput(io.Discard)
}
runtime.GOMAXPROCS(1) // force tests to run on the same (main) thread that gtk.Init is called on
gtk.Init(nil)
setupWidgets()
os.Exit(m.Run())
}
// These tests are partly generated with tools/trace2test.
func TestMinimal(t *testing.T) {
c := NewCore()
assertEqual(t, c.Status, "Starting Unison")
assert.False(t, c.Running)
assert.True(t, c.Busy)
assert.Empty(t, c.Progress)
assert.Empty(t, c.ProgressFraction)
assert.Empty(t, c.Left)
assert.Empty(t, c.Right)
assert.Nil(t, c.Sync)
assert.Nil(t, c.Quit)
assert.Nil(t, c.Abort)
assert.Nil(t, c.Interrupt)
assert.Nil(t, c.Kill)
assert.Zero(t, c.ProcStart())
assert.True(t, c.Running)
assert.Zero(t, c.ProcOutput([]byte("Unison 2.51.3 (ocaml 4.11.1): Contacting server...\n")))
assertEqual(t, c.Status, "Contacting server")
assert.Zero(t, c.ProcOutput([]byte("Looking for changes\n")))
assertEqual(t, c.Status, "Looking for changes")
assert.Zero(t, c.ProcOutput([]byte("Reconciling changes\n")))
assertEqual(t, c.Status, "Reconciling changes")
assert.Zero(t, c.ProcOutput([]byte("\nleft right \n")))
assertEqual(t, c.ProcOutput([]byte("changed ----> one [f] ")),
Update{Input: []byte("l\n")})
assertEqual(t, c.Status, "Assembling plan")
assertEqual(t, c.Left, "left")
assertEqual(t, c.Right, "right")
assert.Zero(t, c.ProcOutput([]byte(" ")))
assert.Zero(t, c.ProcOutput([]byte("changed ----> one \n")))
assert.Zero(t, c.ProcOutput([]byte("left : changed file modified on 2021-02-08 at 18:30:50 size 1146 rw-r--r--\nright : unchanged file modified on 2021-02-08 at 18:30:50 size 1146 rw-r--r--\n")))
assert.Zero(t, c.ProcOutput([]byte("changed ----> one [f] ")))
assertEqual(t, c.Status, "Ready to synchronize")
assert.False(t, c.Busy)
assertEqual(t, c.Items, []Item{
{
Path: "one",
Left: Content{File, Modified, "modified on 2021-02-08 at 18:30:50 size 1146 rw-r--r--"},
Right: Content{File, Unchanged, "modified on 2021-02-08 at 18:30:50 size 1146 rw-r--r--"},
Recommendation: LeftToRight,
},
})
require.NotNil(t, c.Sync)
assert.NotNil(t, c.Quit)
assertEqual(t, c.Sync(),
Update{Input: []byte("0\n")})
assertEqual(t, c.Status, "Starting synchronization")
assert.True(t, c.Busy)
assert.Nil(t, c.Sync)
assert.Nil(t, c.Quit)
assert.NotNil(t, c.Abort)
assertEqual(t, c.ProcOutput([]byte("changed ----> one [f] ")),
Update{Input: []byte(">\n")})
assert.Zero(t, c.ProcOutput([]byte("changed ----> one \n")))
assertEqual(t, c.ProcOutput([]byte("\nProceed with propagating updates? [] ")),
Update{Input: []byte("y\n")})
assert.Zero(t, c.ProcOutput([]byte("Propagating updates\n")))
assertEqual(t, c.Status, "Propagating updates")
assert.Zero(t, c.ProcOutput([]byte("\n\nUNISON 2.51.3 (OCAML 4.11.1) started propagating changes at 18:31:20.92 on 08 Feb 2021\n")))
assert.Zero(t, c.ProcOutput([]byte("[BGN] Updating file one from /home/vasiliy/tmp/gunison/left to /home/vasiliy/tmp/gunison/right\n")))
assert.Zero(t, c.ProcOutput([]byte("100% 00:00 ETA")))
assertEqual(t, c.Progress, "100% 00:00 ETA")
assertEqual(t, c.ProgressFraction, 1.00)
assert.Zero(t, c.ProcOutput([]byte("\r \r")))
assert.Zero(t, c.ProcOutput([]byte("[END] Updating file one\n")))
assert.Zero(t, c.ProcOutput([]byte("100% 00:00 ETA")))
assert.Zero(t, c.ProcOutput([]byte("\r \r")))
assert.Zero(t, c.ProcOutput([]byte("UNISON 2.51.3 (OCAML 4.11.1) finished propagating changes at 18:31:20.92 on 08 Feb 2021\n\n\n")))
assert.Zero(t, c.ProcOutput([]byte("100% 00:00 ETA")))
assert.Zero(t, c.ProcOutput([]byte("\r \r")))
assert.Zero(t, c.ProcOutput([]byte("Saving synchronizer state\n")))
assertEqual(t, c.Status, "Saving synchronizer state")
assert.Empty(t, c.Progress)
assert.Empty(t, c.ProgressFraction)
assertEqual(t, c.ProcOutput([]byte("Synchronization complete at 18:31:20 (1 item transferred, 0 skipped, 0 failed)\n")),
Update{Messages: []Message{
{"Synchronization complete at 18:31:20 (1 item transferred, 0 skipped, 0 failed)", Info},
}})
assertEqual(t, c.Status, "Saving synchronizer state")
assert.True(t, c.Busy)
assert.True(t, c.Running)
assert.Zero(t, c.ProcExit(0, nil))
assertEqual(t, c.Status, "Finished successfully")
assert.False(t, c.Busy)
assert.False(t, c.Running)
assert.NotNil(t, c.Items)
}
func TestTerse(t *testing.T) { // unison -terse
c := NewCore()
assert.Zero(t, c.ProcStart())
assert.Zero(t, c.ProcOutput([]byte("\nleft right \n")))
assertEqual(t, c.ProcOutput([]byte("changed ----> one [f] ")),
Update{Input: []byte("l\n")})
assertEqual(t, c.Status, "Assembling plan")
assertEqual(t, c.Left, "left")
assertEqual(t, c.Right, "right")
assert.Zero(t, c.ProcOutput([]byte(" ")))
assert.Zero(t, c.ProcOutput([]byte("changed ----> one \n")))
assert.Zero(t, c.ProcOutput([]byte("left : changed file modified on 2021-02-07 at 1:50:31 size 1146 rw-r--r--\nright : unchanged file modified on 2021-02-07 at 1:50:31 size 1146 rw-r--r--\n")))
assert.Zero(t, c.ProcOutput([]byte("changed ----> one [f] ")))
assertEqual(t, c.Status, "Ready to synchronize")
assertEqual(t, c.Sync(),
Update{Input: []byte("0\n")})
assertEqual(t, c.ProcOutput([]byte("changed ----> one [f] ")),
Update{Input: []byte(">\n")})
assert.Zero(t, c.ProcOutput([]byte("changed ----> one \n")))
assertEqual(t, c.ProcOutput([]byte("\nProceed with propagating updates? [] ")),
Update{Input: []byte("y\n")})
assertEqual(t, c.Status, "Starting synchronization")
assert.Zero(t, c.ProcOutput([]byte("[BGN] Updating file one from /home/vasiliy/tmp/gunison/left to /home/vasiliy/tmp/gunison/right\n")))
assert.Zero(t, c.ProcOutput([]byte("[END] Updating file one\n")))
assertEqual(t, c.ProcOutput([]byte("Synchronization complete at 01:50:54 (1 item transferred, 0 skipped, 0 failed)\n")),
Update{Messages: []Message{
{"Synchronization complete at 01:50:54 (1 item transferred, 0 skipped, 0 failed)", Info},
}})
assert.Zero(t, c.ProcExit(0, nil))
assertEqual(t, c.Status, "Finished successfully")
}
func TestQuit(t *testing.T) {
c := initCoreMinimalReady(t)
assertEqual(t, c.Quit(),
Update{Input: []byte("q\n")})
assertEqual(t, c.Status, "Quitting Unison")
assert.True(t, c.Running)
assert.True(t, c.Busy)
assert.Nil(t, c.Quit)
assert.Zero(t, c.ProcOutput([]byte("Terminated!\n")))
assertEqual(t, c.ProcExit(3, errors.New("exit status 3")),
Update{Messages: []Message{
{"Terminated!", Info},
{"exit status 3", Error},
}})
assertEqual(t, c.Status, "Unison exited")
assert.False(t, c.Running)
}
func TestKilledExternally(t *testing.T) {
c := initCoreMinimalReady(t)
assertEqual(t, c.ProcExit(-1, errors.New("signal: killed")),
Update{Messages: []Message{
{"signal: killed", Error},
}})
assertEqual(t, c.Status, "Unison exited")
}
func TestProgressLookingForChanges(t *testing.T) {
c := NewCore()
assert.Zero(t, c.ProcStart())
assert.Zero(t, c.ProcOutput([]byte("Unison 2.51.3 (ocaml 4.11.1): Contacting server...\n")))
assert.Zero(t, c.ProcOutput([]byte("Looking for changes\n")))
assertEqual(t, c.ProcOutput([]byte("| some/file")),
Update{Progressed: true})
assertEqual(t, c.Progress, "some/file")
assertEqual(t, c.ProgressFraction, float64(-1))
assert.Zero(t, c.ProcOutput([]byte("\r \r")))
assertEqual(t, c.ProcOutput([]byte("| another/file")),
Update{Progressed: true})
assertEqual(t, c.Progress, "another/file")
assert.Zero(t, c.ProcOutput([]byte("\r \r")))
assertEqual(t, c.ProcOutput([]byte("/ another/file")),
Update{Progressed: true})
assertEqual(t, c.Progress, "another/file")
assert.Zero(t, c.ProcOutput([]byte("\r \r")))
assertEqual(t, c.ProcOutput([]byte("- another/file")),
Update{Progressed: true})
assertEqual(t, c.Progress, "another/file")
assert.Zero(t, c.ProcOutput([]byte("\r \r")))
assertEqual(t, c.ProcOutput([]byte("\\ another/file")),
Update{Progressed: true})
assertEqual(t, c.Progress, "another/file")
assert.Zero(t, c.ProcOutput([]byte("\r \r")))
assertEqual(t, c.ProcOutput([]byte("\\ some file name/so long/that it has...ellipsized to fit into the output")),
Update{Progressed: true})
assertEqual(t, c.Progress, "some file name/so long/that it has...ellipsized to fit into the output")
assert.Zero(t, c.ProcOutput([]byte("\r \r")))
assertEqual(t, c.ProcOutput([]byte("- yet/anoth")),
Update{Progressed: true})
assertEqual(t, c.Progress, "yet/anoth") // report updates as soon as they arrive...
assert.Zero(t, c.ProcOutput([]byte("er/file")))
assertEqual(t, c.Progress, "yet/another/file") // ...but fix up buffering artifacts
assert.Zero(t, c.ProcOutput([]byte("\r \r")))
assert.Zero(t, c.ProcOutput([]byte(" Waiting for changes from server\n")))
assertEqual(t, c.Status, "Waiting for changes from server")
assert.Empty(t, c.Progress)
assert.Empty(t, c.ProgressFraction)
}
func TestProgressPropagatingUpdates(t *testing.T) {
c := initCoreMinimalSyncing(t)
assert.Zero(t, c.ProcOutput([]byte("[BGN] Updating file one from /home/vasiliy/tmp/gunison/left to /home/vasiliy/tmp/gunison/right\n")))
assert.Empty(t, c.Progress)
assert.Empty(t, c.ProgressFraction)
assert.Zero(t, c.ProcOutput([]byte(" 0% 2184:23 ETA")))
assertEqual(t, c.Progress, "0% 2184:23 ETA")
assertEqual(t, c.ProgressFraction, 0.00)
assert.Zero(t, c.ProcOutput([]byte("\r \r")))
assert.Zero(t, c.ProcOutput([]byte(" 0% 73:28 ETA")))
assertEqual(t, c.Progress, "0% 73:28 ETA")
assertEqual(t, c.ProgressFraction, 0.00)
assert.Zero(t, c.ProcOutput([]byte("\r \r")))
assert.Zero(t, c.ProcOutput([]byte(" 8% 07:45 ETA")))
assertEqual(t, c.Progress, "8% 07:45 ETA")
assertEqual(t, c.ProgressFraction, 0.08)
assert.Zero(t, c.ProcOutput([]byte("\r \r")))
assert.Zero(t, c.ProcOutput([]byte(" 13% 07:51 ETA")))
assertEqual(t, c.Progress, "13% 07:51 ETA")
assertEqual(t, c.ProgressFraction, 0.13)
assert.Zero(t, c.ProcOutput([]byte("\r \r")))
assert.Zero(t, c.ProcOutput([]byte(" 14% --:-- ETA")))
assertEqual(t, c.Progress, "14% --:-- ETA")
assertEqual(t, c.ProgressFraction, 0.14)
assert.Zero(t, c.ProcOutput([]byte("\r \r")))
assert.Zero(t, c.ProcOutput([]byte(" 94% 00:01 ETA")))
assertEqual(t, c.Progress, "94% 00:01 ETA")
assertEqual(t, c.ProgressFraction, 0.94)
assert.Zero(t, c.ProcOutput([]byte("\r \r")))
assert.Zero(t, c.ProcOutput([]byte("[END] Updating file one\n")))
assertEqual(t, c.Progress, "94% 00:01 ETA")
assertEqual(t, c.ProgressFraction, 0.94)
}
func TestNonexistentProfile(t *testing.T) {
c := NewCore()
assert.Zero(t, c.ProcStart())
assert.Zero(t, c.ProcOutput([]byte("Usage: unison [options]\n or unison root1 root2 [options]\n or unison profilename [options]\n\nFor a list of options, type \"unison -help\".\nFor a tutorial on basic usage, type \"unison -doc tutorial\".\nFor other documentation, type \"unison -doc topics\".\n\nProfile /home/vasiliy/tmp/gunison/.unison/nonexistent.prf does not exist\n")))
assert.True(t, c.Busy)
assertEqual(t, c.Status, "Starting Unison")
assertEqual(t, c.ProcExit(1, nil),
Update{Messages: []Message{
{"Usage: unison [options]\n or unison root1 root2 [options]\n or unison profilename [options]\n\nFor a list of options, type \"unison -help\".\nFor a tutorial on basic usage, type \"unison -doc tutorial\".\nFor other documentation, type \"unison -doc topics\".\n\nProfile /home/vasiliy/tmp/gunison/.unison/nonexistent.prf does not exist", Info},
}})
assert.False(t, c.Busy)
assertEqual(t, c.Status, "Unison exited")
assert.Nil(t, c.Interrupt)
}
func TestDiff(t *testing.T) {
c := NewCore()
assert.Zero(t, c.ProcStart())
assert.Zero(t, c.ProcOutput([]byte("\nleft right \n")))
assertEqual(t, c.ProcOutput([]byte("changed ----> file1 [f] ")),
Update{Input: []byte("l\n")})
assert.Zero(t, c.ProcOutput([]byte(" ")))
assert.Zero(t, c.ProcOutput([]byte("changed ----> file1 \n")))
assert.Zero(t, c.ProcOutput([]byte("left : changed file modified on 2021-02-13 at 14:29:12 size 1146 rw-r--r--\nright : unchanged file modified on 2021-02-13 at 14:29:12 size 1146 rw-r--r--\n ")))
assert.Zero(t, c.ProcOutput([]byte("changed ----> file2 \n")))
assert.Zero(t, c.ProcOutput([]byte("left : changed file modified on 2021-02-13 at 14:29:12 size 1146 rw-r--r--\nright : unchanged file modified on 2021-02-13 at 14:29:12 size 1146 rw-r--r--\n ")))
assert.Zero(t, c.ProcOutput([]byte("changed ----> file3 \n")))
assert.Zero(t, c.ProcOutput([]byte("left : changed file modified on 2021-02-13 at 14:29:12 size 1146 rw-r--r--\nright : unchanged file modified on 2021-02-13 at 14:29:12 size 1146 rw-r--r--\n ")))
assert.Zero(t, c.ProcOutput([]byte("changed ----> file1 [f] ")))
assertEqual(t, c.Diff("file3"),
Update{Input: []byte("0\n")})
assertEqual(t, c.Status, "Requesting diff")
assert.True(t, c.Busy)
assert.Nil(t, c.Sync)
assert.Nil(t, c.Diff)
assert.Nil(t, c.Quit)
assert.NotNil(t, c.Abort)
assertEqual(t, c.ProcOutput([]byte("changed ----> file1 [f] ")),
Update{Input: []byte("n\n")})
assertEqual(t, c.ProcOutput([]byte("changed ----> file2 [f] ")),
Update{Input: []byte("n\n")})
assertEqual(t, c.ProcOutput([]byte("changed ----> file3 [f] ")),
Update{Input: []byte("d\n")})
assertEqual(t, c.ProcOutput([]byte("\ndiff -u '/home/vasiliy/tmp/gunison/right/file3' '/home/vasiliy/tmp/gunison/left/file3'\n\n--- /home/vasiliy/tmp/gunison/right/file3\t2021-02-13 14:29:12.571303322 +0300\n+++ /home/vasiliy/tmp/gunison/left/file3\t2021-02-13 14:29:12.575303310 +0300\n@@ -1,9 +1,9 @@\n Quia est unde laboriosam. Eum ullam deleniti dolores. Magni quasi facere voluptas. Dolor doloribus aut ut sed officiis id. Et aut nostrum est quia corrupti maiores optio.\n \n-Consectetur fuga sed vitae et nihil quia. Eveniet rerum officia repudiandae tenetur molestiae. Magni ipsum et natus accusantium ut consequatur neque. Veniam in voluptate quia. Culpa labore distinctio laudantium maxime voluptate eaque.\n+Consectetur fuga sed vitae et nihil quia. Eveniet rerum officia repudiandae teonsectetur tempore quia id. Perspiciatis enim corrupti aliquam nam accusamus et molestiae rerum. Sint sit exercitationem corrupti omnis.\n \n-Deserunt dignissimos corrupti aut vel. Laboriosam at labore omnis eos et minus porro perspiciatis. Veniam in dignissimos voluptatem exercitationem excepturi reprehenderit sed optio.\n+Facere asperiores unde rerum dignissimos id. Nihil maiores sequi accusamus eum repudiandae et. Nesciunt ab inveniatis. Veniam in dignissimos voluptatem exercitationem excepturi reprehenderit sed optio.\n \n-Omnis repudiandae nobis autem qui autem possimus. Dolorem id a reprehenderit nihil laboriosam non. Dolor minima in soluta. Magni eveniet magnam velit officia consectetur tempore quia id. Perspiciatis enim corrupti aliquam nam accusamus et molestiae rerum. Sint sit exercitationem corrupti omnis.\n+Omnis repudiandae nobis autem qui autem possimus. Dolorem id a reprehenderit nihil laboriosam non. Dolor minima in soluta. Magni eveniet magnam velit officia cnetur molestiae. Magni ipsum et natus accusantium ut consequatur neque. Veniam in voluptate quia. Culpa labore distinctio laudantium maxime voluptate eaque.\n \n-Facere asperiores unde rerum dignissimos id. Nihil maiores sequi accusamus eum repudiandae et. Nesciunt ab inventore repellat enim illum ratione enim voluptatum. Tempore sint quos tempore fugit rerum sit omnis quae. Minus deserunt aut dolores excepturi qui.\n+Deserunt dignissimos corrupti aut vel. Laboriosam at labore omnis eos et minus porro perspictore repellat enim illum ratione enim voluptatum. Tempore sint quos tempore fugit rerum sit omnis quae. Minus deserunt aut dolores excepturi qui.\n\nchanged ----> file3 [f] ")),
Update{Diff: []byte("--- /home/vasiliy/tmp/gunison/right/file3\t2021-02-13 14:29:12.571303322 +0300\n+++ /home/vasiliy/tmp/gunison/left/file3\t2021-02-13 14:29:12.575303310 +0300\n@@ -1,9 +1,9 @@\n Quia est unde laboriosam. Eum ullam deleniti dolores. Magni quasi facere voluptas. Dolor doloribus aut ut sed officiis id. Et aut nostrum est quia corrupti maiores optio.\n \n-Consectetur fuga sed vitae et nihil quia. Eveniet rerum officia repudiandae tenetur molestiae. Magni ipsum et natus accusantium ut consequatur neque. Veniam in voluptate quia. Culpa labore distinctio laudantium maxime voluptate eaque.\n+Consectetur fuga sed vitae et nihil quia. Eveniet rerum officia repudiandae teonsectetur tempore quia id. Perspiciatis enim corrupti aliquam nam accusamus et molestiae rerum. Sint sit exercitationem corrupti omnis.\n \n-Deserunt dignissimos corrupti aut vel. Laboriosam at labore omnis eos et minus porro perspiciatis. Veniam in dignissimos voluptatem exercitationem excepturi reprehenderit sed optio.\n+Facere asperiores unde rerum dignissimos id. Nihil maiores sequi accusamus eum repudiandae et. Nesciunt ab inveniatis. Veniam in dignissimos voluptatem exercitationem excepturi reprehenderit sed optio.\n \n-Omnis repudiandae nobis autem qui autem possimus. Dolorem id a reprehenderit nihil laboriosam non. Dolor minima in soluta. Magni eveniet magnam velit officia consectetur tempore quia id. Perspiciatis enim corrupti aliquam nam accusamus et molestiae rerum. Sint sit exercitationem corrupti omnis.\n+Omnis repudiandae nobis autem qui autem possimus. Dolorem id a reprehenderit nihil laboriosam non. Dolor minima in soluta. Magni eveniet magnam velit officia cnetur molestiae. Magni ipsum et natus accusantium ut consequatur neque. Veniam in voluptate quia. Culpa labore distinctio laudantium maxime voluptate eaque.\n \n-Facere asperiores unde rerum dignissimos id. Nihil maiores sequi accusamus eum repudiandae et. Nesciunt ab inventore repellat enim illum ratione enim voluptatum. Tempore sint quos tempore fugit rerum sit omnis quae. Minus deserunt aut dolores excepturi qui.\n+Deserunt dignissimos corrupti aut vel. Laboriosam at labore omnis eos et minus porro perspictore repellat enim illum ratione enim voluptatum. Tempore sint quos tempore fugit rerum sit omnis quae. Minus deserunt aut dolores excepturi qui.\n")})
assertEqual(t, c.Status, "Ready to synchronize")
assert.False(t, c.Busy)
assert.NotNil(t, c.Sync)
assert.NotNil(t, c.Diff)
assert.NotNil(t, c.Quit)
assert.Nil(t, c.Abort)
assertEqual(t, c.Diff("file2"),
Update{Input: []byte("0\n")})
assertEqual(t, c.ProcOutput([]byte("changed ----> file1 [f] ")),
Update{Input: []byte("n\n")})
assertEqual(t, c.ProcOutput([]byte("changed ----> file2 [f] ")),
Update{Input: []byte("d\n")})
assertEqual(t, c.ProcOutput([]byte("\ndiff -u '/home/vasiliy/tmp/gunison/right/file2' '/home/vasiliy/tmp/gunison/left/file2'\n\n--- /home/vasiliy/tmp/gunison/right/file2\t2021-02-13 14:29:12.571303322 +0300\n+++ /home/vasiliy/tmp/gunison/left/file2\t2021-02-13 14:29:12.571303322 +0300\n@@ -1,6 +1,6 @@\n-Quia est unde laboriosam. Eum ullam deleniti dolores. Magni quasi facere voluptas. Dolor doloribus aut ut sed officiis id. Et aut nostrum est quia corrupti maiores optio.\n+Quia est unde laboriosam. Eum ullam deleniti dolores. Magni quasi facere voluptas. Dolor doloribus aut consequatur neque. Veniam in voluptate quia. Culpa labore distinctio laudantium maxime voluptate t nihil quia. Eveniet rerum officia repudiandae tenetur molestiae. Magni ipsum et natus accusantium ut ut sed officiis id. Et aut nostrum est quia corrupti maiores optio.\n \n-Consectetur fuga sed vitae et nihil quia. Eveniet rerum officia repudiandae tenetur molestiae. Magni ipsum et natus accusantium ut consequatur neque. Veniam in voluptate quia. Culpa labore distinctio laudantium maxime voluptate eaque.\n+Consectetur fuga sed vitae eeaque.\n \n Deserunt dignissimos corrupti aut vel. Laboriosam at labore omnis eos et minus porro perspiciatis. Veniam in dignissimos voluptatem exercitationem excepturi reprehenderit sed optio.\n \n\nchanged ----> file2 [f] ")),
Update{Diff: []byte("--- /home/vasiliy/tmp/gunison/right/file2\t2021-02-13 14:29:12.571303322 +0300\n+++ /home/vasiliy/tmp/gunison/left/file2\t2021-02-13 14:29:12.571303322 +0300\n@@ -1,6 +1,6 @@\n-Quia est unde laboriosam. Eum ullam deleniti dolores. Magni quasi facere voluptas. Dolor doloribus aut ut sed officiis id. Et aut nostrum est quia corrupti maiores optio.\n+Quia est unde laboriosam. Eum ullam deleniti dolores. Magni quasi facere voluptas. Dolor doloribus aut consequatur neque. Veniam in voluptate quia. Culpa labore distinctio laudantium maxime voluptate t nihil quia. Eveniet rerum officia repudiandae tenetur molestiae. Magni ipsum et natus accusantium ut ut sed officiis id. Et aut nostrum est quia corrupti maiores optio.\n \n-Consectetur fuga sed vitae et nihil quia. Eveniet rerum officia repudiandae tenetur molestiae. Magni ipsum et natus accusantium ut consequatur neque. Veniam in voluptate quia. Culpa labore distinctio laudantium maxime voluptate eaque.\n+Consectetur fuga sed vitae eeaque.\n \n Deserunt dignissimos corrupti aut vel. Laboriosam at labore omnis eos et minus porro perspiciatis. Veniam in dignissimos voluptatem exercitationem excepturi reprehenderit sed optio.\n \n")})
assertEqual(t, c.Diff("file1"),
Update{Input: []byte("0\n")})
assertEqual(t, c.ProcOutput([]byte("changed ----> file1 [f] ")),
Update{Input: []byte("d\n")})
assertEqual(t, c.ProcOutput([]byte("\ndiff -u '/home/vasiliy/tmp/gunison/right/file1' '/home/vasiliy/tmp/gunison/left/file1'\n\n--- /home/vasiliy/tmp/gunison/right/file1\t2021-02-13 14:29:12.571303322 +0300\n+++ /home/vasiliy/tmp/gunison/left/file1\t2021-02-13 14:29:12.571303322 +0300\n@@ -1,6 +1,6 @@\n-Quia est unde laboriosam. Eum ullam deleniti dolores. Magni quasi facere voluptas. Dolor doloribus aut ut sed officiis id. Et aut nostrum est quia corrupti maiores optio.\n+Quia est unde laboriosam. Eum ullam deleniti dolorrupti maiores optio.\n \n-Consectetur fuga sed vitae et nihil quia. Eveniet rerum officia repudiandae tenetur molestiae. Magni ipsum et natus accusantium ut consequatur neque. Veniam in voluptate quia. Culpa labore distinctio laudantium maxime voluptate eaque.\n+Consectetur fuga sed vitae eut ut sed officiis id. Et aut nostrum est quia cores. Magni quasi facere voluptas. Dolor doloribus at nihil quia. Eveniet rerum officia repudiandae tenetur molestiae. Magni ipsum et natus accusantium ut consequatur neque. Veniam in voluptate quia. Culpa labore distinctio laudantium maxime voluptate eaque.\n \n Deserunt dignissimos corrupti aut vel. Laboriosam at labore omnis eos et minus porro perspiciatis. Veniam in dignissimos voluptatem exercitationem excepturi reprehenderit sed optio.\n \n\nchanged ----> file1 [f] ")),
Update{Diff: []byte("--- /home/vasiliy/tmp/gunison/right/file1\t2021-02-13 14:29:12.571303322 +0300\n+++ /home/vasiliy/tmp/gunison/left/file1\t2021-02-13 14:29:12.571303322 +0300\n@@ -1,6 +1,6 @@\n-Quia est unde laboriosam. Eum ullam deleniti dolores. Magni quasi facere voluptas. Dolor doloribus aut ut sed officiis id. Et aut nostrum est quia corrupti maiores optio.\n+Quia est unde laboriosam. Eum ullam deleniti dolorrupti maiores optio.\n \n-Consectetur fuga sed vitae et nihil quia. Eveniet rerum officia repudiandae tenetur molestiae. Magni ipsum et natus accusantium ut consequatur neque. Veniam in voluptate quia. Culpa labore distinctio laudantium maxime voluptate eaque.\n+Consectetur fuga sed vitae eut ut sed officiis id. Et aut nostrum est quia cores. Magni quasi facere voluptas. Dolor doloribus at nihil quia. Eveniet rerum officia repudiandae tenetur molestiae. Magni ipsum et natus accusantium ut consequatur neque. Veniam in voluptate quia. Culpa labore distinctio laudantium maxime voluptate eaque.\n \n Deserunt dignissimos corrupti aut vel. Laboriosam at labore omnis eos et minus porro perspiciatis. Veniam in dignissimos voluptatem exercitationem excepturi reprehenderit sed optio.\n \n")})
}
func TestDiffRandom(t *testing.T) {
// Like TestDiff, but chunks of Unison output get buffered randomly before arriving to Gunison.
c := NewCore()
assert.Zero(t, c.ProcStart())
assertEqual(t, c.ProcOutput([]byte("Unison 2.51.3 (ocaml 4.11.1): Contacting server...\nLooking for changes\n/ file2\r \rReconciling changes\n\nleft right \nchanged ----> file1 [f] ")),
Update{
Progressed: true,
Input: []byte("l\n"),
})
assert.Zero(t, c.ProcOutput([]byte(" changed ----> file1 \nleft : changed file modified on 2021-")))
assert.Zero(t, c.ProcOutput([]byte("03-22 at 11:21:26 size 1146 rw-r--r--\nrig")))
assert.Zero(t, c.ProcOutput([]byte("ht : unchanged file modified on 2021-03-22 at 11")))
assert.Zero(t, c.ProcOutput([]byte(":21:26 size 1146 rw-r--r--\n changed ----> file2 \nleft : changed file modified on 2021-03-22 at 11:21:26 size 1146 rw-r--r--\nright : un")))
assert.Zero(t, c.ProcOutput([]byte("changed file m")))
assert.Zero(t, c.ProcOutput([]byte("odified on 2021-03-22 at ")))
assert.Zero(t, c.ProcOutput([]byte("11:21:26 size 1146 rw-r--r--\n changed ----> file3 \nleft : changed file modified on 2021-03-22 at 11:21:26 ")))
assert.Zero(t, c.ProcOutput([]byte(" size 1146 rw-r--r--\nright : unchanged file modified on 2021-03-22 at 11:21:26 size 1146 rw-r--r--\nchanged ----> file1 [f] ")))
assertEqual(t, c.Diff("file3"),
Update{Input: []byte("0\n")})
assert.Zero(t, c.ProcOutput([]byte("changed ----> file1 ")))
assertEqual(t, c.ProcOutput([]byte("[f] ")),
Update{Input: []byte("n\n")})
assert.Zero(t, c.ProcOutput([]byte("changed ----> file2 [f]")))
assertEqual(t, c.ProcOutput([]byte(" ")),
Update{Input: []byte("n\n")})
assertEqual(t, c.ProcOutput([]byte("changed ----> file3 [f] ")),
Update{Input: []byte("d\n")})
assert.Zero(t, c.ProcOutput([]byte("\ndiff -u '/home/vasiliy/tmp/gunison/right/file3' '/home/vasiliy/tmp/gunison/left/file3'\n\n")))
assert.Zero(t, c.ProcOutput([]byte("--- /home/vasiliy/tmp/guniso")))
assert.Zero(t, c.ProcOutput([]byte("n/right/file3\t2021-03-22 11:21:26.165184522 +0300\n+++ /home/vasiliy/tmp/gu")))
assert.Zero(t, c.ProcOutput([]byte("nison/left/file3\t2021-03-22 11:21:26.165184522 +0300\n@@ -1,9 +1,9 @@\n-Quia est unde laboriosam. Eum ullam delen")))
assert.Zero(t, c.ProcOutput([]byte("iti dolores. Magni quasi facere voluptas. Dolor doloribus aut ut sed officiis id. Et aut nostrum est quia corrupti maiores optio.\n+Quia est unde laboriosam. Eum ullam deleniti dolores. Magni quasi facere voluptas. Dolor doloribus aut ut sed offi")))
assert.Zero(t, c.ProcOutput([]byte("ciis id. Et aut nostrum est quia cororiosam at labore omnis eos et minus porro perspiciatis. Veniam in dignissimos voluptatem exercitatio")))
assert.Zero(t, c.ProcOutput([]byte("nem excepturi reprehenderit sed optio.\n \n-Consectetur fuga sed vitae et nihil quia. Eveniet rerum officia repudiandae tenetur molestiae. Magni ipsum et natus accusantium ut consequatur neque. Veniam in volu")))
assert.Zero(t, c.ProcOutput([]byte("ptate quia. Culpa labore distinctio laudantium maxime voluptate eaque.\n+Omnis reput consequatur")))
assert.Zero(t, c.ProcOutput([]byte(" neque. Veniam in voluptate quia. Culpa labore distinctio laudanti")))
assert.Zero(t, c.ProcOutput([]byte("um maxime voluptate eaque.\n \n-Deserunt dignissimos corrupti aut vel. Laboriosam at labore omnis eos et minus porro perspiciatis.")))
assert.Zero(t, c.ProcOutput([]byte(" Veniam in dignissimos voluptatem exercitationem excepturi")))
assert.Zero(t, c.ProcOutput([]byte(" reprehenderit sed optio.\n+Deserunt dignissimos corrupti aut vel. Labrupti maiores optio.\n \n-Omnis repudiandae nobis autem qui autem possimus. Dolo")))
assert.Zero(t, c.ProcOutput([]byte("rem id a reprehenderit nihil laboriosam non. Dolor minima in soluta. Magni eveniet magnam velit officia consectetur tempore quia id. Perspiciatis enim corrupti aliquam nam accusamus et molestiae rerum. Sint sit exercitationem corrupti omnis.\n+Cons")))
assert.Zero(t, c.ProcOutput([]byte("ectetur fuga sed vitae et nihil quia. Eveniet rerum officia repudiandae tenetur molestiae. Magni ipsum et natus accusantium udiandae nobis autem qui autem possimus. Dolorem id a reprehend")))
assert.Zero(t, c.ProcOutput([]byte("erit nihil laboriosam non. Dolor minima in soluta. Magni eveniet magnam velit officia co")))
assert.Zero(t, c.ProcOutput([]byte("nsectetur tempore quia id. Perspiciatis enim corrupti aliquam nam accusamus et molestiae r")))
assert.Zero(t, c.ProcOutput([]byte("erum. Sint sit ")))
assert.Zero(t, c.ProcOutput([]byte("exercitationem corrupti omnis.\n \n Facere asperiores unde rerum dignissimos id. Nihil maiores sequi accusamus eum repudiandae et. Nesciunt ab inventore repellat enim illum ratione enim voluptatum. Tempore sint quos tempore fugit rerum sit omn")))
assert.Zero(t, c.ProcOutput([]byte("is quae. Minus deserunt aut dolores excepturi qui.\n\nchanged ----> ")))
assertEqual(t, c.ProcOutput([]byte("file3 [f] ")),
Update{Diff: []byte("--- /home/vasiliy/tmp/gunison/right/file3\t2021-03-22 11:21:26.165184522 +0300\n+++ /home/vasiliy/tmp/gunison/left/file3\t2021-03-22 11:21:26.165184522 +0300\n@@ -1,9 +1,9 @@\n-Quia est unde laboriosam. Eum ullam deleniti dolores. Magni quasi facere voluptas. Dolor doloribus aut ut sed officiis id. Et aut nostrum est quia corrupti maiores optio.\n+Quia est unde laboriosam. Eum ullam deleniti dolores. Magni quasi facere voluptas. Dolor doloribus aut ut sed officiis id. Et aut nostrum est quia cororiosam at labore omnis eos et minus porro perspiciatis. Veniam in dignissimos voluptatem exercitationem excepturi reprehenderit sed optio.\n \n-Consectetur fuga sed vitae et nihil quia. Eveniet rerum officia repudiandae tenetur molestiae. Magni ipsum et natus accusantium ut consequatur neque. Veniam in voluptate quia. Culpa labore distinctio laudantium maxime voluptate eaque.\n+Omnis reput consequatur neque. Veniam in voluptate quia. Culpa labore distinctio laudantium maxime voluptate eaque.\n \n-Deserunt dignissimos corrupti aut vel. Laboriosam at labore omnis eos et minus porro perspiciatis. Veniam in dignissimos voluptatem exercitationem excepturi reprehenderit sed optio.\n+Deserunt dignissimos corrupti aut vel. Labrupti maiores optio.\n \n-Omnis repudiandae nobis autem qui autem possimus. Dolorem id a reprehenderit nihil laboriosam non. Dolor minima in soluta. Magni eveniet magnam velit officia consectetur tempore quia id. Perspiciatis enim corrupti aliquam nam accusamus et molestiae rerum. Sint sit exercitationem corrupti omnis.\n+Consectetur fuga sed vitae et nihil quia. Eveniet rerum officia repudiandae tenetur molestiae. Magni ipsum et natus accusantium udiandae nobis autem qui autem possimus. Dolorem id a reprehenderit nihil laboriosam non. Dolor minima in soluta. Magni eveniet magnam velit officia consectetur tempore quia id. Perspiciatis enim corrupti aliquam nam accusamus et molestiae rerum. Sint sit exercitationem corrupti omnis.\n \n Facere asperiores unde rerum dignissimos id. Nihil maiores sequi accusamus eum repudiandae et. Nesciunt ab inventore repellat enim illum ratione enim voluptatum. Tempore sint quos tempore fugit rerum sit omnis quae. Minus deserunt aut dolores excepturi qui.\n")})
assertEqual(t, c.Diff("file2"),
Update{Input: []byte("0\n")})
assertEqual(t, c.ProcOutput([]byte("changed ----> file1 [f] ")),
Update{Input: []byte("n\n")})
assertEqual(t, c.ProcOutput([]byte("changed ----> file2 [f] ")),
Update{Input: []byte("d\n")})
assert.Zero(t, c.ProcOutput([]byte("\ndiff -u '/home/vasiliy/tmp/gunison/right/file2' '/home/vasiliy/tmp/gunison/left/file2'\n\n--- /home/vasiliy/tmp/gunison/right/file")))
assert.Zero(t, c.ProcOutput([]byte("2\t2021-03-22 11:21:26.165184522 +0300\n+++ /home/vasiliy/")))
assert.Zero(t, c.ProcOutput([]byte("tmp/gunison/left/file2\t2021-03-22 11:21:26.165184522 +0300\n@@ -1,6 +1,6 @@\n-Quia est unde laboriosam. Eum ullam deleniti dolores. Magni quasi facere voluptas. Dolor doloribus aut ut sed officiis id. Et aut nostrum est quia corrupti maior")))
assert.Zero(t, c.ProcOutput([]byte("es optio.\n+Quia est unde labori")))
assert.Zero(t, c.ProcOutput([]byte("osam. Eum ullam deleniti dolores. Magni quasi facere voluptas. Dolor doloribus aut consequatur neque. Veniam in voluptate quia. Culpa labore distinctio laudantium maxime voluptate t nihil quia. Eveniet rerum officia repudiandae tenetur molestiae. Magni ipsum et natus accusantium ut ut")))
assert.Zero(t, c.ProcOutput([]byte(" sed officiis id. Et aut nostrum est quia corrupti maiores optio.\n \n-Consectetur fuga sed vitae et nihil quia. Eveniet rerum o")))
assert.Zero(t, c.ProcOutput([]byte("fficia repudi")))
assert.Zero(t, c.ProcOutput([]byte("andae tenetur molestiae. Magni ipsum et natus accusantium ut consequatur neque. Veniam in voluptate quia. Culpa labore distinctio laudantium maxime voluptate eaque.\n+Consectetur fuga sed vit")))
assert.Zero(t, c.ProcOutput([]byte("ae eeaque.\n \n Deserunt dignissimos corrupti aut vel. Laboriosam at labore omnis eos et minus p")))
assert.Zero(t, c.ProcOutput([]byte("orro perspiciatis. Veniam in dignissimos voluptatem exercitatio")))
assertEqual(t, c.ProcOutput([]byte("nem excepturi reprehenderit sed optio.\n \n\nchanged ----> file2 [f] ")),
Update{Diff: []byte("--- /home/vasiliy/tmp/gunison/right/file2\t2021-03-22 11:21:26.165184522 +0300\n+++ /home/vasiliy/tmp/gunison/left/file2\t2021-03-22 11:21:26.165184522 +0300\n@@ -1,6 +1,6 @@\n-Quia est unde laboriosam. Eum ullam deleniti dolores. Magni quasi facere voluptas. Dolor doloribus aut ut sed officiis id. Et aut nostrum est quia corrupti maiores optio.\n+Quia est unde laboriosam. Eum ullam deleniti dolores. Magni quasi facere voluptas. Dolor doloribus aut consequatur neque. Veniam in voluptate quia. Culpa labore distinctio laudantium maxime voluptate t nihil quia. Eveniet rerum officia repudiandae tenetur molestiae. Magni ipsum et natus accusantium ut ut sed officiis id. Et aut nostrum est quia corrupti maiores optio.\n \n-Consectetur fuga sed vitae et nihil quia. Eveniet rerum officia repudiandae tenetur molestiae. Magni ipsum et natus accusantium ut consequatur neque. Veniam in voluptate quia. Culpa labore distinctio laudantium maxime voluptate eaque.\n+Consectetur fuga sed vitae eeaque.\n \n Deserunt dignissimos corrupti aut vel. Laboriosam at labore omnis eos et minus porro perspiciatis. Veniam in dignissimos voluptatem exercitationem excepturi reprehenderit sed optio.\n \n")})
assertEqual(t, c.Diff("file1"),
Update{Input: []byte("0\n")})
assertEqual(t, c.ProcOutput([]byte("changed ----> file1 [f] ")),
Update{Input: []byte("d\n")})
assert.Zero(t, c.ProcOutput([]byte("\ndiff -u '/home/vasiliy/tmp/gunison/right/file1' '/home/vasiliy/tmp/gunison/left/file1'\n\n--- /home/vasiliy/tmp/gunison/right/file1\t2021-03-22 11:21:26.165184522 +0300\n+++ /home/v")))
assert.Zero(t, c.ProcOutput([]byte("asiliy/tmp/gunison/left/file1\t2021-03-22 11:21:26.165184522 +0300\n@@ -1,6 +1,6 @@\n-Quia est unde laboriosam. Eum ullam delen")))
assert.Zero(t, c.ProcOutput([]byte("iti dolores. Magni quasi facere voluptas. Dolor doloribus aut ut sed officiis id. Et aut nostrum est quia corrupti maiores optio.\n+Quia est unde laboriosam. Eum ullam deleniti dolorrupti maiores optio.\n \n-Consectetur fuga sed vitae et nihil quia. Eveniet reru")))
assert.Zero(t, c.ProcOutput([]byte("m officia repudiandae tenetur molestiae. Magni ipsum et natus accusantium ut consequatur neque. Veniam in voluptate quia. Culpa labore distinctio laudant")))
assert.Zero(t, c.ProcOutput([]byte("ium maxime voluptate eaque.\n+Consectetur fuga sed vitae e")))
assert.Zero(t, c.ProcOutput([]byte("ut ut sed officiis id. Et aut nostrum est quia cores. Magni quasi facere voluptas. Dolor doloribus at nihil quia. Eveniet")))
assert.Zero(t, c.ProcOutput([]byte(" rerum officia repudiandae tenetur molestiae. Magni ipsum et natus accusantium ut consequatur neque. Veniam in voluptate quia. Culpa labore distinctio laudantium maxime voluptate eaque.\n \n ")))
assert.Zero(t, c.ProcOutput([]byte("Deserunt dignissimos corrupti aut vel. Laboriosam at labore omnis eos et minus porro perspiciatis. ")))
assert.Zero(t, c.ProcOutput([]byte("Veniam in dignissimos voluptatem exercitationem excepturi reprehenderit sed optio.\n \n\nchanged ---->")))
assertEqual(t, c.ProcOutput([]byte(" file1 [f] ")),
Update{Diff: []byte("--- /home/vasiliy/tmp/gunison/right/file1\t2021-03-22 11:21:26.165184522 +0300\n+++ /home/vasiliy/tmp/gunison/left/file1\t2021-03-22 11:21:26.165184522 +0300\n@@ -1,6 +1,6 @@\n-Quia est unde laboriosam. Eum ullam deleniti dolores. Magni quasi facere voluptas. Dolor doloribus aut ut sed officiis id. Et aut nostrum est quia corrupti maiores optio.\n+Quia est unde laboriosam. Eum ullam deleniti dolorrupti maiores optio.\n \n-Consectetur fuga sed vitae et nihil quia. Eveniet rerum officia repudiandae tenetur molestiae. Magni ipsum et natus accusantium ut consequatur neque. Veniam in voluptate quia. Culpa labore distinctio laudantium maxime voluptate eaque.\n+Consectetur fuga sed vitae eut ut sed officiis id. Et aut nostrum est quia cores. Magni quasi facere voluptas. Dolor doloribus at nihil quia. Eveniet rerum officia repudiandae tenetur molestiae. Magni ipsum et natus accusantium ut consequatur neque. Veniam in voluptate quia. Culpa labore distinctio laudantium maxime voluptate eaque.\n \n Deserunt dignissimos corrupti aut vel. Laboriosam at labore omnis eos et minus porro perspiciatis. Veniam in dignissimos voluptatem exercitationem excepturi reprehenderit sed optio.\n \n")})
}
func TestDiffNoOutput(t *testing.T) {
// When the diff command produces no output, it's probably a GUI one, so we silently ignore it.
c := initCoreMinimalReady(t)
assertEqual(t, c.Diff("one"),
Update{Input: []byte("0\n")})
assertEqual(t, c.Status, "Requesting diff")
assertEqual(t, c.ProcOutput([]byte("changed ----> one [f] ")),
Update{Input: []byte("d\n")})
assert.Zero(t, c.ProcOutput([]byte("\ntrue '/home/vasiliy/tmp/gunison/left/one' '/home/vasiliy/tmp/gunison/right/one'\n\n\n\nchanged ----> one [f] ")))
assertEqual(t, c.Status, "Ready to synchronize")
}
func TestDiffDirectory(t *testing.T) {
c := NewCore()
assert.Zero(t, c.ProcStart())
assert.Zero(t, c.ProcOutput([]byte("\nleft right \n")))
assertEqual(t, c.ProcOutput([]byte("changed <-?-> new dir one hundred/one hundred one [] ")),
Update{Input: []byte("l\n")})
assert.Zero(t, c.ProcOutput([]byte(" ")))
assert.Zero(t, c.ProcOutput([]byte("changed <-?-> new dir one hundred/one hundred one \n")))
assert.Zero(t, c.ProcOutput([]byte("left : changed file modified on 2021-02-13 at 14:56:44 size 1000 rw-r--r--\nright : new dir modified on 2021-02-13 at 14:56:44 size 2292 rwxr-xr-x\n ")))
assert.Zero(t, c.ProcOutput([]byte("changed <-?-> new dir one hundred/one hundred one [] ")))
assertEqual(t, c.Diff("one hundred/one hundred one"),
Update{Input: []byte("0\n")})
assertEqual(t, c.ProcOutput([]byte("changed <-?-> new dir one hundred/one hundred one [] ")),
Update{Input: []byte("d\n")})
assertEqual(t, c.ProcOutput([]byte("Can't diff: path doesn't refer to a file in both replicas\nchanged <-?-> new dir one hundred/one hundred one [] ")),
Update{Messages: []Message{
{"Can't diff: path doesn't refer to a file in both replicas", Error},
}})
assertEqual(t, c.Status, "Ready to synchronize")
}
func TestDiffAbort(t *testing.T) {
c := NewCore()
assert.Zero(t, c.ProcStart())
assert.Zero(t, c.ProcOutput([]byte("\nleft right \n")))
assertEqual(t, c.ProcOutput([]byte("changed ----> file1 [f] ")),
Update{Input: []byte("l\n")})
assert.Zero(t, c.ProcOutput([]byte(" ")))
assert.Zero(t, c.ProcOutput([]byte("changed ----> file1 \n")))
assert.Zero(t, c.ProcOutput([]byte("left : changed file modified on 2021-02-13 at 15:12:12 size 1146 rw-r--r--\nright : unchanged file modified on 2021-02-13 at 15:12:12 size 1146 rw-r--r--\n ")))
assert.Zero(t, c.ProcOutput([]byte("changed ----> file2 \n")))
assert.Zero(t, c.ProcOutput([]byte("left : changed file modified on 2021-02-13 at 15:12:12 size 1146 rw-r--r--\nright : unchanged file modified on 2021-02-13 at 15:12:12 size 1146 rw-r--r--\n ")))
assert.Zero(t, c.ProcOutput([]byte("changed ----> file1 [f] ")))
assertEqual(t, c.Diff("file2"),
Update{Input: []byte("0\n")})
assertEqual(t, c.ProcOutput([]byte("changed ----> file1 [f] ")),
Update{Input: []byte("n\n")})
// While we're still seeking to the requested file in Unison prompt, we can abort gracefully.
assert.Zero(t, c.Abort())
assertEqual(t, c.Status, "Waiting for Unison")
assert.True(t, c.Busy)
assert.Nil(t, c.Sync)
assert.Zero(t, c.ProcOutput([]byte("changed ----> file2 ")))
assertEqual(t, c.Status, "Waiting for Unison")
assert.Zero(t, c.ProcOutput([]byte("[f] ")))
assertEqual(t, c.Status, "Ready to synchronize")
assert.False(t, c.Busy)
assert.NotNil(t, c.Sync)
assertEqual(t, c.Diff("file2"),
Update{Input: []byte("0\n")})
assertEqual(t, c.ProcOutput([]byte("changed ----> file1 [f] ")),
Update{Input: []byte("n\n")})
assertEqual(t, c.ProcOutput([]byte("changed ----> file2 [f] ")),
Update{Input: []byte("d\n")})
// But if we have already requested the diff, the only way to abort is by interrupting.
assertEqual(t, c.Abort(),
Update{Interrupt: true})
}
func TestDiffBadCommand(t *testing.T) { // unison -diff 'diff --bad-option'
c := initCoreMinimalReady(t)
assertEqual(t, c.Diff("one"),
Update{Input: []byte("0\n")})
assertEqual(t, c.ProcOutput([]byte("changed ----> one [f] ")),
Update{Input: []byte("d\n")})
assert.Zero(t, c.ProcOutput([]byte("diff: unrecognized option '--bad-option'\n")))
assert.Zero(t, c.ProcOutput([]byte("diff: ")))
assert.Zero(t, c.ProcOutput([]byte("Try 'diff --help' for more information.\n")))
assertEqual(t, c.ProcOutput([]byte("\ndiff --bad-option '/home/vasiliy/tmp/gunison/left/one' '/home/vasiliy/tmp/gunison/right/one'\n\n\n\nchanged ----> one [f] ")),
Update{Messages: []Message{
// Unison prefixes diff output with a blank line, the command line, and two more blank lines.
// This means that anything printed after the prompt but before a blank line is definitely *not*
// normal diff output.
{"diff: unrecognized option '--bad-option'\ndiff: Try 'diff --help' for more information.", Warning},
}})
assertEqual(t, c.Status, "Ready to synchronize")
}
func TestDiffBadItem(t *testing.T) {
c := initCoreMinimalReady(t)
assertEqual(t, c.Diff("two"),
Update{Input: []byte("0\n")})
assertEqual(t, c.ProcOutput([]byte("changed ----> one [f] ")),
Update{Input: []byte("n\n")})
assertEqual(t, c.ProcOutput([]byte("\nProceed with propagating updates? [] ")),
Update{
Interrupt: true,
Messages: []Message{
{"Failed to find 'two' in Unison prompts.\nThis is probably a bug in Gunison. Unison will be stopped now.", Error},
},
})
}
func TestMerge(t *testing.T) {
c := initCoreMinimalReady(t)
c.Items[0].Override = Merge
assertEqual(t, c.Sync(),
Update{Input: []byte("0\n")})
assertEqual(t, c.ProcOutput([]byte("changed ----> one [f] ")),
Update{Input: []byte("m\n")})
assert.Zero(t, c.ProcOutput([]byte("changed <=M=> one \n")))
assertEqual(t, c.ProcOutput([]byte("\nProceed with propagating updates? [] ")),
Update{Input: []byte("y\n")})
assert.Zero(t, c.ProcOutput([]byte("Merge command: meld ''/home/vasiliy/tmp/gunison/left/.unison.merge1-one'' ''/home/vasiliy/tmp/gunison/left/.unison.merge2-one''\n")))
assert.Zero(t, c.ProcOutput([]byte("Merge result (exited (0)):\n\n")))
assert.Zero(t, c.ProcOutput([]byte("No outputs detected \n")))
assert.Zero(t, c.ProcOutput([]byte("No output from merge cmd and both original files are still present\n")))
assert.Zero(t, c.ProcOutput([]byte("Merge program made files equal\n")))
assertEqual(t, c.ProcOutput([]byte("Warning: 'backupcurrent' is not set for path one\n")),
Update{Messages: []Message{
{"Warning: 'backupcurrent' is not set for path one", Warning},
}})
assertEqual(t, c.ProcOutput([]byte("Synchronization complete at 16:40:04 (1 item transferred, 0 skipped, 0 failed)\n")),
Update{Messages: []Message{
{"Synchronization complete at 16:40:04 (1 item transferred, 0 skipped, 0 failed)", Info},
}})
assert.Zero(t, c.ProcExit(0, nil))
assertEqual(t, c.Status, "Finished successfully")
}
func TestMergeFailed(t *testing.T) {
c := initCoreMinimalReady(t)
c.Items[0].Override = Merge
assertEqual(t, c.Sync(),
Update{Input: []byte("0\n")})
assertEqual(t, c.ProcOutput([]byte("changed ----> one [f] ")),
Update{Input: []byte("m\n")})
assert.Zero(t, c.ProcOutput([]byte("changed <=M=> one \n")))
assertEqual(t, c.ProcOutput([]byte("\nProceed with propagating updates? [] ")),
Update{Input: []byte("y\n")})
assert.Zero(t, c.ProcOutput([]byte("Merge command: meld ''/home/vasiliy/tmp/gunison/left/.unison.merge1-one'' ''/home/vasiliy/tmp/gunison/left/.unison.merge2-one''\n")))
assert.Zero(t, c.ProcOutput([]byte("Merge result (exited (0)):\n\n")))
assert.Zero(t, c.ProcOutput([]byte("No outputs detected \n")))
assert.Zero(t, c.ProcOutput([]byte("No output from merge cmd and both original files are still present\n")))
assertEqual(t, c.ProcOutput([]byte("\nFailed [one]: Merge program didn't change either temp file\n")),
Update{Messages: []Message{
{"Failed [one]: Merge program didn't change either temp file", Error},
}})
assertEqual(t, c.ProcOutput([]byte("Synchronization incomplete at 16:49:21 (0 items transferred, 0 skipped, 1 failed)\n")),
Update{Messages: []Message{
{"Synchronization incomplete at 16:49:21 (0 items transferred, 0 skipped, 1 failed)", Warning},
}})
assert.Zero(t, c.ProcExit(2, nil))
assertEqual(t, c.Status, "Finished with errors")
}
func TestMergeDir(t *testing.T) {
c := NewCore()
assert.Zero(t, c.ProcStart())
assert.Zero(t, c.ProcOutput([]byte("\nleft right \n")))
assertEqual(t, c.ProcOutput([]byte("new dir ----> one [f] ")),
Update{Input: []byte("l\n")})
assert.Zero(t, c.ProcOutput([]byte(" ")))
assert.Zero(t, c.ProcOutput([]byte("new dir ----> one \n")))
assert.Zero(t, c.ProcOutput([]byte("left : new dir modified on 2021-02-25 at 17:06:22 size 0 rwxrwxr-x\nright : absent\n")))
assert.Zero(t, c.ProcOutput([]byte("new dir ----> one [f] ")))
c.Items[0].Override = Merge
assertEqual(t, c.Sync(),
Update{Input: []byte("0\n")})
assertEqual(t, c.ProcOutput([]byte("new dir ----> one [f] ")),
Update{Input: []byte("m\n")})
assert.Zero(t, c.ProcOutput([]byte("new dir <=M=> one \n")))
assertEqual(t, c.ProcOutput([]byte("\nProceed with propagating updates? [] ")),
Update{Input: []byte("y\n")})
assertEqual(t, c.ProcOutput([]byte("Failed [one]: Can only merge two existing files\n")),
Update{Messages: []Message{
{"Failed [one]: Can only merge two existing files", Error},
}})
assertEqual(t, c.ProcOutput([]byte("Synchronization incomplete at 17:06:28 (0 items transferred, 0 skipped, 1 failed)\n")),
Update{Messages: []Message{
{"Synchronization incomplete at 17:06:28 (0 items transferred, 0 skipped, 1 failed)", Warning},
}})
assertEqual(t, c.ProcOutput([]byte(" failed: one\n")),
Update{Messages: []Message{
{"failed: one", Error},
}})
assert.Zero(t, c.ProcExit(2, nil))
assertEqual(t, c.Status, "Finished with errors")
}
func TestMergeBadProgram(t *testing.T) { // unison -merge 'Name * -> nonexistent-program'
c := initCoreMinimalReady(t)
c.Items[0].Override = Merge
assertEqual(t, c.Sync(),
Update{Input: []byte("0\n")})
assertEqual(t, c.ProcOutput([]byte("changed ----> one [f] ")),
Update{Input: []byte("m\n")})
assert.Zero(t, c.ProcOutput([]byte("changed <=M=> one \n")))
assertEqual(t, c.ProcOutput([]byte("\nProceed with propagating updates? [] ")),
Update{Input: []byte("y\n")})
assert.Zero(t, c.ProcOutput([]byte("Merge command: nonexistent-program\n")))
assertEqual(t, c.ProcOutput([]byte("Merge result (exited (127)):\n/bin/sh: 1: nonexistent-program: not found\n\nExited with status 127\n")),
Update{Messages: []Message{
{"Merge result (exited (127)):", Warning},
{"/bin/sh: 1: nonexistent-program: not found", Info},
{"Exited with status 127", Info},
}})
assert.Zero(t, c.ProcOutput([]byte("No outputs detected \n")))
assert.Zero(t, c.ProcOutput([]byte("No output from merge cmd and both original files are still present\n")))
assertEqual(t, c.ProcOutput([]byte("/bin/sh: 1: nonexistent-program: not found\n\nExited with status 127\nFailed [one]: Merge program didn't change either temp file\n")),
Update{Messages: []Message{
{"/bin/sh: 1: nonexistent-program: not found", Info},
{"Exited with status 127", Info},
{"Failed [one]: Merge program didn't change either temp file", Error},
}})
}
// TODO: tests for merge cases other than "No output from merge cmd and both original files are still present"
func TestReplicaMissing(t *testing.T) {
c := NewCore()
assert.Zero(t, c.ProcStart())
assert.Zero(t, c.ProcOutput([]byte("Unison 2.51.3 (ocaml 4.11.1): Contacting server...\n")))
assert.Zero(t, c.ProcOutput([]byte("Looking for changes\n")))
assert.Zero(t, c.ProcOutput([]byte("Reconciling changes\n")))
assert.Zero(t, c.ProcOutput([]byte("The root of one of the replicas has been completely emptied.\nUnison may delete everything in the other replica. (Set the \n'confirmbigdel' preference to false to disable this check.)\n\n")))
upd := c.ProcOutput([]byte("Do you really want to proceed? [] "))
assertEqual(t, upd.Alert.Text, "The root of one of the replicas has been completely emptied.\nUnison may delete everything in the other replica. (Set the \n'confirmbigdel' preference to false to disable this check.)\n\nDo you really want to proceed?")
assertEqual(t, upd.Alert.Importance, Warning)
assertEqual(t, c.Status, "Reconciling changes")
assert.True(t, c.Busy)
assertEqual(t, upd.Alert.Proceed(),
Update{Input: []byte("y\n")})
assert.Zero(t, c.ProcOutput([]byte("\nleft right \n")))
assertEqual(t, c.ProcOutput([]byte(" <---- deleted [f] ")),
Update{Input: []byte("l\n")})
assert.Zero(t, c.ProcOutput([]byte(" ")))
assert.Zero(t, c.ProcOutput([]byte(" <---- deleted \n")))
assert.Zero(t, c.ProcOutput([]byte("left : unchanged dir modified on 2021-02-06 at 18:31:42 size 1146 rwxr-xr-x\nright : deleted\n")))
assert.Zero(t, c.ProcOutput([]byte(" <---- deleted [f] ")))
assertEqual(t, c.Status, "Ready to synchronize")
assertEqual(t, c.Items, []Item{
{
Path: "",
Left: Content{Directory, Unchanged, "modified on 2021-02-06 at 18:31:42 size 1146 rwxr-xr-x"},
Right: Content{Absent, Deleted, ""},
Recommendation: RightToLeft,
},
})
assert.False(t, c.Busy)
assert.NotNil(t, c.Sync)
}
func TestReplicaMissingAbort(t *testing.T) {
c := NewCore()
assert.Zero(t, c.ProcStart())
assert.Zero(t, c.ProcOutput([]byte("The root of one of the replicas has been completely emptied.\nUnison may delete everything in the other replica. (Set the \n'confirmbigdel' preference to false to disable this check.)\n\n")))
upd := c.ProcOutput([]byte("Do you really want to proceed? [] "))
assertEqual(t, upd.Alert.Abort(),
Update{Input: []byte("q\n")})
assertEqual(t, c.Status, "Quitting Unison")
}
func TestNewReplicas(t *testing.T) {
c := NewCore()
assert.Zero(t, c.ProcStart())
assert.Zero(t, c.ProcOutput([]byte("Unison 2.51.3 (ocaml 4.11.1): Contacting server...\n")))
assert.Zero(t, c.ProcOutput([]byte("Looking for changes\n")))
assert.Zero(t, c.ProcOutput([]byte("Warning: ")))
assert.Zero(t, c.ProcOutput([]byte("No archive files were found for these roots, whose canonical names are:\n\t/home/vasiliy/tmp/gunison/left\n\t/home/vasiliy/tmp/gunison/right\nThis can happen either\nbecause this is the first time you have synchronized these roots, \nor because you have upgraded Unison to a new version with a different\narchive format. \n\nUpdate detection may take a while on this run if the replicas are \nlarge.\n\nUnison will assume that the 'last synchronized state' of both replicas\nwas completely empty. This means that any files that are different\nwill be reported as conflicts, and any files that exist only on one\nreplica will be judged as new and propagated to the other replica.\nIf the two replicas are identical, then no changes will be reported.\n\nIf you see this message repeatedly, it may be because one of your machines\nis getting its address from DHCP, which is causing its host name to change\nbetween synchronizations. See the documentation for the UNISONLOCALHOSTNAME\nenvironment variable for advice on how to correct this.\n\nDonations to the Unison project are gratefully accepted: \nhttp://www.cis.upenn.edu/~bcpierce/unison\n\n\n")))
assert.Zero(t, c.ProcOutput([]byte("Press return to continue.[")))
upd := c.ProcOutput([]byte("<spc>] "))
assertEqual(t, upd.Alert.Text, "Warning: No archive files were found for these roots, whose canonical names are:\n\t/home/vasiliy/tmp/gunison/left\n\t/home/vasiliy/tmp/gunison/right\nThis can happen either\nbecause this is the first time you have synchronized these roots, \nor because you have upgraded Unison to a new version with a different\narchive format. \n\nUpdate detection may take a while on this run if the replicas are \nlarge.\n\nUnison will assume that the 'last synchronized state' of both replicas\nwas completely empty. This means that any files that are different\nwill be reported as conflicts, and any files that exist only on one\nreplica will be judged as new and propagated to the other replica.\nIf the two replicas are identical, then no changes will be reported.\n\nIf you see this message repeatedly, it may be because one of your machines\nis getting its address from DHCP, which is causing its host name to change\nbetween synchronizations. See the documentation for the UNISONLOCALHOSTNAME\nenvironment variable for advice on how to correct this.\n\nDonations to the Unison project are gratefully accepted: \nhttp://www.cis.upenn.edu/~bcpierce/unison")
assertEqual(t, upd.Alert.Importance, Warning)
assertEqual(t, c.Status, "Looking for changes")
assert.True(t, c.Busy)
assertEqual(t, upd.Alert.Proceed(),
Update{Input: []byte("\n")})
assert.Zero(t, c.ProcOutput([]byte("Reconciling changes\n")))
assertEqual(t, c.Status, "Reconciling changes")
}
func TestNewReplicasAbort(t *testing.T) {
c := NewCore()
assert.Zero(t, c.ProcStart())
assert.Zero(t, c.ProcOutput([]byte("Warning: ")))
assert.Zero(t, c.ProcOutput([]byte("No archive files were found for these roots, whose canonical names are:\n\t/home/vasiliy/tmp/gunison/left\n\t/home/vasiliy/tmp/gunison/right\nThis can happen either\nbecause this is the first time you have synchronized these roots, \nor because you have upgraded Unison to a new version with a different\narchive format. \n\nUpdate detection may take a while on this run if the replicas are \nlarge.\n\nUnison will assume that the 'last synchronized state' of both replicas\nwas completely empty. This means that any files that are different\nwill be reported as conflicts, and any files that exist only on one\nreplica will be judged as new and propagated to the other replica.\nIf the two replicas are identical, then no changes will be reported.\n\nIf you see this message repeatedly, it may be because one of your machines\nis getting its address from DHCP, which is causing its host name to change\nbetween synchronizations. See the documentation for the UNISONLOCALHOSTNAME\nenvironment variable for advice on how to correct this.\n\nDonations to the Unison project are gratefully accepted: \nhttp://www.cis.upenn.edu/~bcpierce/unison\n\n\n")))
assert.Zero(t, c.ProcOutput([]byte("Press return to continue.[")))
upd := c.ProcOutput([]byte("<spc>] "))
assertEqual(t, upd.Alert.Abort(),
Update{Input: []byte("q\n")})
assertEqual(t, c.Status, "Quitting Unison")
}
func TestEmpty(t *testing.T) {
c := NewCore()
assert.Zero(t, c.ProcStart())
assert.Zero(t, c.ProcOutput([]byte("Nothing to do: replicas have not changed since last sync.\n")))
assertEqual(t, c.ProcExit(0, nil),
Update{Messages: []Message{
{"Nothing to do: replicas have not changed since last sync.", Info},
}})
assertEqual(t, c.Status, "Finished successfully")
assert.False(t, c.Running)
}
func TestIdenticalChanges(t *testing.T) {
c := NewCore()
assert.Zero(t, c.ProcStart())
assert.Zero(t, c.ProcOutput([]byte("Unison 2.51.3 (ocaml 4.11.1): Contacting server...\n")))
assert.Zero(t, c.ProcOutput([]byte("Permission denied, please try again.\n")))
assert.Zero(t, c.ProcOutput([]byte("Looking for changes\n")))
assert.Zero(t, c.ProcOutput([]byte("Reconciling changes\n")))
assert.Zero(t, c.ProcOutput([]byte("Nothing to do: replicas have been changed only in identical ways since last sync.\n")))
assertEqual(t, c.Status, "Reconciling changes")
assertEqual(t, c.ProcExit(0, nil),
Update{Messages: []Message{
{"Nothing to do: replicas have been changed only in identical ways since last sync.", Info},
}})
assertEqual(t, c.Status, "Finished successfully")
assert.False(t, c.Running)
}
func TestAssorted(t *testing.T) {
c := NewCore()
assert.Zero(t, c.ProcStart())
assert.Zero(t, c.ProcOutput([]byte("\nlocal tanais \n")))
assertEqual(t, c.ProcOutput([]byte("changed <-?-> new dir one hundred/one hundred one [] ")),
Update{Input: []byte("l\n")})
assert.Zero(t, c.ProcOutput([]byte(" ")))
assert.Zero(t, c.ProcOutput([]byte("changed <-?-> new dir one hundred/one hundred one \n")))
assert.Zero(t, c.ProcOutput([]byte("local : changed file modified on 2021-02-06 at 18:41:58 size 1000 rw-r--r--\ntanais : new dir modified on 2021-02-06 at 18:41:58 size 2292 rwxr-xr-x\n ")))
assert.Zero(t, c.ProcOutput([]byte("new file <-?-> deleted one hundred/one hundred two \n")))
assert.Zero(t, c.ProcOutput([]byte("local : new file modified on 2021-02-06 at 18:41:58 size 1146 rw-r--r--\ntanais : deleted\n ")))
assert.Zero(t, c.ProcOutput([]byte("changed <-?-> changed six/nine \n")))
assert.Zero(t, c.ProcOutput([]byte("local : changed file modified on 2021-02-06 at 18:41:58 size 1147000 rw-r--r--\ntanais : changed file modified on 2021-02-06 at 18:41:58 size 1147000 rw-rw-r--\n ")))
assert.Zero(t, c.ProcOutput([]byte("props <-?-> props twenty one \n")))
assert.Zero(t, c.ProcOutput([]byte("local : changed props modified on 2021-02-06 at 18:41:58 size 1146 rw-r--r--\ntanais : changed props modified on 2021-02-06 at 18:41:58 size 1146 rw-rw-r--\n ")))
assert.Zero(t, c.ProcOutput([]byte(" <---- changed deeply/nested/sub/directory/with/file \n")))
assert.Zero(t, c.ProcOutput([]byte("local : unchanged file modified on 2021-02-06 at 18:41:58 size 1146 rw-r--r--\ntanais : changed file modified on 2021-02-06 at 18:41:58 size 1146 rw-rw-r--\n ")))
assert.Zero(t, c.ProcOutput([]byte("new link ----> eighteen \n")))
assert.Zero(t, c.ProcOutput([]byte("local : new symlink modified on 1970-01-01 at 3:00:00 size 0 unknown permissions\ntanais : absent\n ")))
assert.Zero(t, c.ProcOutput([]byte(" <---- changed here is a rather long and funny file name, 社會科學院語學研究所\t\v\f \u0085 \u1680\u2002\u2003\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u202f\u205f\u3000゚・✿ヾ╲(。◕‿◕。)╱✿・゚/here is a rather long and funny file name, 社會科學院語學研究所\t\v\f \u0085 \u1680\u2002\u2003\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u202f\u205f\u3000゚・✿ヾ╲(。◕‿◕。)╱✿・゚ \n")))
assert.Zero(t, c.ProcOutput([]byte("local : unchanged file modified on 2021-02-06 at 18:41:58 size 1146 rw-r--r--\ntanais : changed file modified on 2021-02-06 at 18:41:58 size 1146 rw-rw-r--\n ")))
assert.Zero(t, c.ProcOutput([]byte("new file ----> seventeen \n")))
assert.Zero(t, c.ProcOutput([]byte("local : new file modified on 2021-02-06 at 18:41:58 size 0 rw-r--r--\ntanais : absent\n ")))
assert.Zero(t, c.ProcOutput([]byte(" <---- changed six/eight \n")))
assert.Zero(t, c.ProcOutput([]byte("local : unchanged file modified on 2021-02-06 at 18:41:58 size 1146 rw-r--r--\ntanais : changed file modified on 2021-02-06 at 18:41:58 size 1147000 rw-rw-r--\n ")))
assert.Zero(t, c.ProcOutput([]byte(" <---- changed six/eleven \n")))
assert.Zero(t, c.ProcOutput([]byte("local : unchanged file modified on 2021-02-06 at 18:41:58 size 10000000 rw-r--r--\ntanais : changed file modified on 2021-02-06 at 18:41:58 size 10000000 rw-rw-r--\n ")))
assert.Zero(t, c.ProcOutput([]byte(" <---- deleted six/fourteen \n")))
assert.Zero(t, c.ProcOutput([]byte("local : unchanged dir modified on 2021-02-06 at 18:41:58 size 2292 rwxr-xr-x\ntanais : deleted\n ")))
assert.Zero(t, c.ProcOutput([]byte(" <---- changed six/seven \n")))
assert.Zero(t, c.ProcOutput([]byte("local : unchanged file modified on 2021-02-06 at 18:41:58 size 0 rw-r--r--\ntanais : changed file modified on 2021-02-06 at 18:41:58 size 1146 rw-rw-r--\n ")))
assert.Zero(t, c.ProcOutput([]byte("props ----> six/ten \n")))
assert.Zero(t, c.ProcOutput([]byte("local : changed props modified on 2021-02-06 at 18:41:58 size 1000 rwx------\ntanais : unchanged file modified on 2021-02-06 at 18:41:58 size 1000 rw-r--r--\n ")))
assert.Zero(t, c.ProcOutput([]byte(" <---- deleted three \n")))
assert.Zero(t, c.ProcOutput([]byte("local : unchanged file modified on 2021-02-06 at 18:41:58 size 1147000 rw-r--r--\ntanais : deleted\n ")))
assert.Zero(t, c.ProcOutput([]byte(" <---- props twelve \n")))
assert.Zero(t, c.ProcOutput([]byte("local : unchanged dir modified on 2021-02-06 at 18:41:58 size 0 rwxr-xr-x\ntanais : dir props changed modified on 2021-02-06 at 18:41:58 size 0 rwx------\n ")))
assert.Zero(t, c.ProcOutput([]byte(" <---- new dir twenty \n")))
assert.Zero(t, c.ProcOutput([]byte("local : absent\ntanais : new dir modified on 2021-02-06 at 18:41:58 size 0 rwxr-xr-x\n ")))
assert.Zero(t, c.ProcOutput([]byte("changed ----> two \n")))
assert.Zero(t, c.ProcOutput([]byte("local : changed file modified on 2021-02-06 at 18:41:58 size 1146 rw-r--r--\ntanais : unchanged file modified on 2021-02-06 at 18:41:58 size 1146 rw-r--r--\n")))
assert.Zero(t, c.ProcOutput([]byte("changed <-?-> new dir one hundred/one hundred one [] ")))
assertEqual(t, c.Items, []Item{
{
Path: "one hundred/one hundred one",
Left: Content{File, Modified, "modified on 2021-02-06 at 18:41:58 size 1000 rw-r--r--"},
Right: Content{Directory, Created, "modified on 2021-02-06 at 18:41:58 size 2292 rwxr-xr-x"},
Recommendation: Skip,
},
{
Path: "one hundred/one hundred two",
Left: Content{File, Created, "modified on 2021-02-06 at 18:41:58 size 1146 rw-r--r--"},
Right: Content{Absent, Deleted, ""},
Recommendation: Skip,
},
{
Path: "six/nine",
Left: Content{File, Modified, "modified on 2021-02-06 at 18:41:58 size 1147000 rw-r--r--"},
Right: Content{File, Modified, "modified on 2021-02-06 at 18:41:58 size 1147000 rw-rw-r--"},
Recommendation: Skip,
},
{
Path: "twenty one",
Left: Content{File, PropsChanged, "modified on 2021-02-06 at 18:41:58 size 1146 rw-r--r--"},
Right: Content{File, PropsChanged, "modified on 2021-02-06 at 18:41:58 size 1146 rw-rw-r--"},
Recommendation: Skip,
},
{
Path: "deeply/nested/sub/directory/with/file",
Left: Content{File, Unchanged, "modified on 2021-02-06 at 18:41:58 size 1146 rw-r--r--"},
Right: Content{File, Modified, "modified on 2021-02-06 at 18:41:58 size 1146 rw-rw-r--"},
Recommendation: RightToLeft,
},
{
Path: "eighteen",
Left: Content{Symlink, Created, "modified on 1970-01-01 at 3:00:00 size 0 unknown permissions"},
Right: Content{Type: Absent},
Recommendation: LeftToRight,
},
{
Path: "here is a rather long and funny file name, 社會科學院語學研究所\t\v\f \u0085 \u1680\u2002\u2003\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u202f\u205f\u3000゚・✿ヾ╲(。◕‿◕。)╱✿・゚/here is a rather long and funny file name, 社會科學院語學研究所\t\v\f \u0085 \u1680\u2002\u2003\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u202f\u205f\u3000゚・✿ヾ╲(。◕‿◕。)╱✿・゚",
Left: Content{File, Unchanged, "modified on 2021-02-06 at 18:41:58 size 1146 rw-r--r--"},
Right: Content{File, Modified, "modified on 2021-02-06 at 18:41:58 size 1146 rw-rw-r--"},
Recommendation: RightToLeft,
},
{
Path: "seventeen",
Left: Content{File, Created, "modified on 2021-02-06 at 18:41:58 size 0 rw-r--r--"},
Right: Content{Type: Absent},
Recommendation: LeftToRight,
},
{
Path: "six/eight",
Left: Content{File, Unchanged, "modified on 2021-02-06 at 18:41:58 size 1146 rw-r--r--"},
Right: Content{File, Modified, "modified on 2021-02-06 at 18:41:58 size 1147000 rw-rw-r--"},
Recommendation: RightToLeft,
},
{
Path: "six/eleven",
Left: Content{File, Unchanged, "modified on 2021-02-06 at 18:41:58 size 10000000 rw-r--r--"},
Right: Content{File, Modified, "modified on 2021-02-06 at 18:41:58 size 10000000 rw-rw-r--"},
Recommendation: RightToLeft,
},
{
Path: "six/fourteen",
Left: Content{Directory, Unchanged, "modified on 2021-02-06 at 18:41:58 size 2292 rwxr-xr-x"},
Right: Content{Type: Absent, Status: Deleted},
Recommendation: RightToLeft,
},
{
Path: "six/seven",
Left: Content{File, Unchanged, "modified on 2021-02-06 at 18:41:58 size 0 rw-r--r--"},
Right: Content{File, Modified, "modified on 2021-02-06 at 18:41:58 size 1146 rw-rw-r--"},
Recommendation: RightToLeft,
},
{
Path: "six/ten",
Left: Content{File, PropsChanged, "modified on 2021-02-06 at 18:41:58 size 1000 rwx------"},
Right: Content{File, Unchanged, "modified on 2021-02-06 at 18:41:58 size 1000 rw-r--r--"},
Recommendation: LeftToRight,
},
{
Path: "three",
Left: Content{File, Unchanged, "modified on 2021-02-06 at 18:41:58 size 1147000 rw-r--r--"},
Right: Content{Type: Absent, Status: Deleted},
Recommendation: RightToLeft,
},
{
Path: "twelve",
Left: Content{Directory, Unchanged, "modified on 2021-02-06 at 18:41:58 size 0 rwxr-xr-x"},
Right: Content{Directory, PropsChanged, "modified on 2021-02-06 at 18:41:58 size 0 rwx------"},
Recommendation: RightToLeft,
},
{
Path: "twenty",
Left: Content{Type: Absent},
Right: Content{Directory, Created, "modified on 2021-02-06 at 18:41:58 size 0 rwxr-xr-x"},
Recommendation: RightToLeft,
},
{
Path: "two",
Left: Content{File, Modified, "modified on 2021-02-06 at 18:41:58 size 1146 rw-r--r--"},
Right: Content{File, Unchanged, "modified on 2021-02-06 at 18:41:58 size 1146 rw-r--r--"},
Recommendation: LeftToRight,
},
})
c.Items[0].Override = LeftToRight
c.Items[2].Override = RightToLeft
c.Items[3].Override = RightToLeft
c.Items[6].Override = LeftToRight
c.Items[14].Override = Skip
c.Items[16].Override = Merge
assertEqual(t, c.Sync(),
Update{Input: []byte("0\n")})
assertEqual(t, c.Status, "Starting synchronization")
assertEqual(t, c.ProcOutput([]byte("changed <-?-> new dir one hundred/one hundred one [] ")),
Update{Input: []byte(">\n")})
assert.Zero(t, c.ProcOutput([]byte("changed ====> new dir one hundred/one hundred one \n")))
assertEqual(t, c.ProcOutput([]byte("new file <-?-> deleted one hundred/one hundred two [] ")),
Update{Input: []byte("/\n")})
assert.Zero(t, c.ProcOutput([]byte("new file <-?-> deleted one hundred/one hundred two \n")))
assertEqual(t, c.ProcOutput([]byte("changed <-?-> changed six/nine [] ")),
Update{Input: []byte("<\n")})
assert.Zero(t, c.ProcOutput([]byte("changed <==== changed six/nine \n")))
assertEqual(t, c.ProcOutput([]byte("props <-?-> props twenty one [] ")),
Update{Input: []byte("<\n")})
assert.Zero(t, c.ProcOutput([]byte("props <==== props twenty one \n")))
assertEqual(t, c.ProcOutput([]byte(" <---- changed deeply/nested/sub/directory/with/file [f] ")),
Update{Input: []byte("<\n")})
assert.Zero(t, c.ProcOutput([]byte(" <---- changed deeply/nested/sub/directory/with/file \n")))
assertEqual(t, c.ProcOutput([]byte("new link ----> eighteen [f] ")),
Update{Input: []byte(">\n")})
assert.Zero(t, c.ProcOutput([]byte("new link ----> eighteen \n")))
assertEqual(t, c.ProcOutput([]byte(" <---- changed here is a rather long and funny file name, 社會科學院語學研究所\t\v\f \u0085 \u1680\u2002\u2003\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u202f\u205f\u3000゚・✿ヾ╲(。◕‿◕。)╱✿・゚/here is a rather long and funny file name, 社會科學院語學研究所\t\v\f \u0085 \u1680\u2002\u2003\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u202f\u205f\u3000゚・✿ヾ╲(。◕‿◕。)╱✿・゚ [f] ")),
Update{Input: []byte(">\n")})
assert.Zero(t, c.ProcOutput([]byte(" ====> changed here is a rather long and funny file name, 社會科學院語學研究所\t\v\f \u0085 \u1680\u2002\u2003\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u202f\u205f\u3000゚・✿ヾ╲(。◕‿◕。)╱✿・゚/here is a rather long and funny file name, 社會科學院語學研究所\t\v\f \u0085 \u1680\u2002\u2003\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u202f\u205f\u3000゚・✿ヾ╲(。◕‿◕。)╱✿・゚ \n")))
assertEqual(t, c.ProcOutput([]byte("new file ----> seventeen [f] ")),
Update{Input: []byte(">\n")})
assert.Zero(t, c.ProcOutput([]byte("new file ----> seventeen \n")))
assertEqual(t, c.ProcOutput([]byte(" <---- changed six/eight [f] ")),
Update{Input: []byte("<\n")})
assert.Zero(t, c.ProcOutput([]byte(" <---- changed six/eight \n")))
assertEqual(t, c.ProcOutput([]byte(" <---- changed six/eleven [f] ")),
Update{Input: []byte("<\n")})
assert.Zero(t, c.ProcOutput([]byte(" <---- changed six/eleven \n")))
assertEqual(t, c.ProcOutput([]byte(" <---- deleted six/fourteen [f] ")),
Update{Input: []byte("<\n")})
assert.Zero(t, c.ProcOutput([]byte(" <---- deleted six/fourteen \n")))
assertEqual(t, c.ProcOutput([]byte(" <---- changed six/seven [f] ")),
Update{Input: []byte("<\n")})
assert.Zero(t, c.ProcOutput([]byte(" <---- changed six/seven \n")))
assertEqual(t, c.ProcOutput([]byte("props ----> six/ten [f] ")),
Update{Input: []byte(">\n")})
assert.Zero(t, c.ProcOutput([]byte("props ----> six/ten \n")))
assertEqual(t, c.ProcOutput([]byte(" <---- deleted three [f] ")),
Update{Input: []byte("<\n")})
assert.Zero(t, c.ProcOutput([]byte(" <---- deleted three \n")))
assertEqual(t, c.ProcOutput([]byte(" <---- props twelve [f] ")),
Update{Input: []byte("/\n")})
assert.Zero(t, c.ProcOutput([]byte(" <=?=> props twelve \n")))
assertEqual(t, c.ProcOutput([]byte(" <---- new dir twenty [f] ")),
Update{Input: []byte("<\n")})
assert.Zero(t, c.ProcOutput([]byte(" <---- new dir twenty \n")))
assertEqual(t, c.ProcOutput([]byte("changed ----> two [f] ")),
Update{Input: []byte("m\n")})
assert.Zero(t, c.ProcOutput([]byte("changed <=M=> two \n")))
assertEqual(t, c.ProcOutput([]byte("\nProceed with propagating updates? [] ")),
Update{Input: []byte("y\n")})
assert.Zero(t, c.ProcOutput([]byte("Propagating updates\n")))
assert.Zero(t, c.ProcOutput([]byte("\n\nUNISON 2.51.3 (OCAML 4.11.1) started propagating changes at 16:24:22.00 on 17 Feb 2021\n")))
assert.Zero(t, c.ProcOutput([]byte("[BGN] Copying one hundred/one hundred one from /home/vasiliy/tmp/gunison/left to //tanais//home/vasiliy/tmp/gunison/right\n")))
assert.Zero(t, c.ProcOutput([]byte("[CONFLICT] Skipping one hundred/one hundred two\n conflicting updates\n")))
assert.Zero(t, c.ProcOutput([]byte("[BGN] Updating file six/nine from //tanais//home/vasiliy/tmp/gunison/right to /home/vasiliy/tmp/gunison/left\n")))
assert.Zero(t, c.ProcOutput([]byte("[BGN] Copying properties for twenty one from //tanais//home/vasiliy/tmp/gunison/right to /home/vasiliy/tmp/gunison/left\n")))
assert.Zero(t, c.ProcOutput([]byte("[BGN] Updating file deeply/nested/sub/directory/with/file from //tanais//home/vasiliy/tmp/gunison/right to /home/vasiliy/tmp/gunison/left\n")))
assert.Zero(t, c.ProcOutput([]byte("[BGN] Copying eighteen from /home/vasiliy/tmp/gunison/left to //tanais//home/vasiliy/tmp/gunison/right\n")))
assert.Zero(t, c.ProcOutput([]byte("[BGN] Updating file here is a rather long and funny file name, 社會科學院語學研究所\t\v\f \u0085 \u1680\u2002\u2003\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u202f\u205f\u3000゚・✿ヾ╲(。◕‿◕。)╱✿・゚/here is a rather long and funny file name, 社會科學院語學研究所\t\v\f \u0085 \u1680\u2002\u2003\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u202f\u205f\u3000゚・✿ヾ╲(。◕‿◕。)╱✿・゚ from /home/vasiliy/tmp/gunison/left to //tanais//home/vasiliy/tmp/gunison/right\n")))
assert.Zero(t, c.ProcOutput([]byte("[BGN] Copying seventeen from /home/vasiliy/tmp/gunison/left to //tanais//home/vasiliy/tmp/gunison/right\n")))
assert.Zero(t, c.ProcOutput([]byte("[BGN] Updating file six/eight from //tanais//home/vasiliy/tmp/gunison/right to /home/vasiliy/tmp/gunison/left\n")))
assert.Zero(t, c.ProcOutput([]byte("[BGN] Updating file six/eleven from //tanais//home/vasiliy/tmp/gunison/right to /home/vasiliy/tmp/gunison/left\n")))
assert.Zero(t, c.ProcOutput([]byte("[BGN] Updating file six/seven from //tanais//home/vasiliy/tmp/gunison/right to /home/vasiliy/tmp/gunison/left\n")))
assert.Zero(t, c.ProcOutput([]byte("[BGN] Copying properties for six/ten from /home/vasiliy/tmp/gunison/left to //tanais//home/vasiliy/tmp/gunison/right\n")))
assert.Zero(t, c.ProcOutput([]byte("[CONFLICT] Skipping twelve\n skip requested\n")))
assert.Zero(t, c.ProcOutput([]byte("[BGN] Copying twenty from //tanais//home/vasiliy/tmp/gunison/right to /home/vasiliy/tmp/gunison/left\n")))
assert.Zero(t, c.ProcOutput([]byte(" 0% 00:55 ETA")))
assert.Zero(t, c.ProcOutput([]byte("\r \r")))
assert.Zero(t, c.ProcOutput([]byte("[END] Copying properties for twenty one\n")))
assert.Zero(t, c.ProcOutput([]byte(" 0% 00:55 ETA")))
assert.Zero(t, c.ProcOutput([]byte("\r \r")))
assert.Zero(t, c.ProcOutput([]byte(" 0% 00:04 ETA")))
assert.Zero(t, c.ProcOutput([]byte("\r \r")))
assert.Zero(t, c.ProcOutput([]byte(" 1% 00:02 ETA")))
assert.Zero(t, c.ProcOutput([]byte("\r \r")))
assert.Zero(t, c.ProcOutput([]byte(" 2% 00:01 ETA")))
assert.Zero(t, c.ProcOutput([]byte("\r \r")))