forked from dolthub/dolt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathremotes.bats
714 lines (673 loc) · 20.9 KB
/
remotes.bats
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
#!/usr/bin/env bats
load $BATS_TEST_DIRNAME/helper/common.bash
setup() {
setup_common
cd $BATS_TMPDIR
mkdir remotes-$$
mkdir remotes-$$/empty
echo remotesrv log available here $BATS_TMPDIR/remotes-$$/remotesrv.log
remotesrv --http-port 1234 --dir ./remotes-$$ &> ./remotes-$$/remotesrv.log 3>&- &
cd dolt-repo-$$
mkdir "dolt-repo-clones"
}
teardown() {
teardown_common
pgrep remotesrv | xargs kill
rm -rf $BATS_TMPDIR/remotes-$$
}
@test "dolt remotes server is running" {
pgrep remotesrv
}
@test "add a remote using dolt remote" {
run dolt remote add test-remote http://localhost:50051/test-org/test-repo
[ "$status" -eq 0 ]
[ "$output" = "" ]
run dolt remote -v
[ "$status" -eq 0 ]
[[ "$output" =~ "test-remote" ]] || false
run dolt remote add test-remote
[ "$status" -eq 1 ]
[[ "$output" =~ "usage:" ]] || false
}
@test "remove a remote" {
dolt remote add test-remote http://localhost:50051/test-org/test-repo
run dolt remote remove test-remote
[ "$status" -eq 0 ]
[ "$output" = "" ]
run dolt remote -v
[ "$status" -eq 0 ]
[[ ! "$output" =~ "test-remote" ]] || false
run dolt remote remove poop
[ "$status" -eq 1 ]
[[ "$output" =~ "unknown remote poop" ]] || false
}
@test "push and pull an unknown remote" {
dolt remote add test-remote http://localhost:50051/test-org/test-repo
run dolt push poop master
[ "$status" -eq 1 ]
[[ "$output" =~ "unknown remote" ]] || false
run dolt pull poop
[ "$status" -eq 1 ]
[[ "$output" =~ "unknown remote" ]] || false
}
@test "push with only one argument" {
dolt remote add test-remote http://localhost:50051/test-org/test-repo
run dolt push test-remote
[ "$status" -eq 1 ]
skip "Bad error message for only one command to push"
[[ !"$output" =~ "unable to find" ]] || false
[[ "$output" =~ "must specify remote and branch" ]] || false
}
@test "push and pull master branch from a remote" {
dolt remote add test-remote http://localhost:50051/test-org/test-repo
run dolt push test-remote master
[ "$status" -eq 0 ]
[ -d "$BATS_TMPDIR/remotes-$$/test-org/test-repo" ]
run dolt pull test-remote
[ "$status" -eq 0 ]
skip "Should say Already up to date not fast forward"
[[ "$output" = "up to date" ]] || false
}
@test "push and pull non-master branch from remote" {
dolt remote add test-remote http://localhost:50051/test-org/test-repo
dolt checkout -b test-branch
run dolt push test-remote test-branch
[ "$status" -eq 0 ]
run dolt pull test-remote
[ "$status" -eq 0 ]
skip "Should say up to date not fast forward"
[[ "$output" = "up to date" ]] || false
}
@test "push and pull from non-master branch and use --set-upstream" {
dolt remote add test-remote http://localhost:50051/test-org/test-repo
dolt checkout -b test-branch
run dolt push --set-upstream test-remote test-branch
[ "$status" -eq 0 ]
[[ ! "$output" =~ "panic:" ]] || false
dolt sql -q "create table test (pk int, c1 int, primary key(pk))"
dolt add .
dolt commit -m "Added test table"
run dolt push
[ "$status" -eq 0 ]
}
@test "push and pull with docs from remote" {
dolt remote add test-remote http://localhost:50051/test-org/test-repo
echo "license-text" > LICENSE.md
echo "readme-text" > README.md
dolt add .
dolt commit -m "test doc commit"
dolt push test-remote master
cd "dolt-repo-clones"
run dolt clone http://localhost:50051/test-org/test-repo
[ "$status" -eq 0 ]
cd test-repo
run dolt log
[ "$status" -eq 0 ]
[[ "$output" =~ "test doc commit" ]] || false
cd ../../
echo "updated-license" > LICENSE.md
dolt add .
dolt commit -m "updated license"
dolt push test-remote master
cd dolt-repo-clones/test-repo
echo "this text should remain after pull :p" > README.md
run dolt pull
[[ "$output" =~ "Updating" ]] || false
run dolt log
[ "$status" -eq 0 ]
[[ "$output" =~ "updated license" ]] || false
run cat LICENSE.md
[ "$status" -eq 0 ]
[[ "$output" =~ "updated-license" ]] || false
run cat README.md
[ "$status" -eq 0 ]
[[ "$output" =~ "this text should remain after pull :p" ]] || false
}
@test "clone a remote" {
dolt remote add test-remote http://localhost:50051/test-org/test-repo
dolt sql <<SQL
CREATE TABLE test (
pk BIGINT NOT NULL COMMENT 'tag:0',
c1 BIGINT COMMENT 'tag:1',
c2 BIGINT COMMENT 'tag:2',
c3 BIGINT COMMENT 'tag:3',
c4 BIGINT COMMENT 'tag:4',
c5 BIGINT COMMENT 'tag:5',
PRIMARY KEY (pk)
);
SQL
dolt add test
dolt commit -m "test commit"
dolt push test-remote master
cd "dolt-repo-clones"
run dolt clone http://localhost:50051/test-org/test-repo
[ "$status" -eq 0 ]
[[ "$output" =~ "cloning http://localhost:50051/test-org/test-repo" ]] || false
cd test-repo
run dolt log
[ "$status" -eq 0 ]
[[ "$output" =~ "test commit" ]] || false
run dolt status
[ "$status" -eq 0 ]
[[ ! "$output" =~ "LICENSE.md" ]] || false
[[ ! "$output" =~ "README.md" ]] || false
run ls
[ "$status" -eq 0 ]
[[ ! "$output" =~ "LICENSE.md" ]] || false
[[ ! "$output" =~ "README.md" ]] || false
}
@test "clone a remote with docs" {
dolt remote add test-remote http://localhost:50051/test-org/test-repo
echo "license-text" > LICENSE.md
echo "readme-text" > README.md
dolt add .
dolt commit -m "test doc commit"
dolt push test-remote master
cd "dolt-repo-clones"
run dolt clone http://localhost:50051/test-org/test-repo
[ "$status" -eq 0 ]
[[ "$output" =~ "cloning http://localhost:50051/test-org/test-repo" ]] || false
cd test-repo
run dolt log
[ "$status" -eq 0 ]
[[ "$output" =~ "test doc commit" ]] || false
run dolt status
[ "$status" -eq 0 ]
[[ ! "$output" =~ "LICENSE.md" ]] || false
[[ ! "$output" =~ "README.md" ]] || false
run ls
[ "$status" -eq 0 ]
[[ "$output" =~ "LICENSE.md" ]] || false
[[ "$output" =~ "README.md" ]] || false
run cat LICENSE.md
[ "$status" -eq 0 ]
[[ "$output" =~ "license-text" ]] || false
run cat README.md
[ "$status" -eq 0 ]
[[ "$output" =~ "readme-text" ]] || false
}
@test "clone an empty remote" {
run dolt clone http://localhost:50051/test-org/empty
[ "$status" -eq 0 ]
cd empty
run dolt status
[ "$status" -eq 0 ]
run ls
[[ ! "$output" =~ "LICENSE.md" ]] || false
[[ ! "$output" =~ "README.md" ]] || false
run dolt remote -v
[ "$status" -eq 0 ]
[[ "$output" =~ "origin" ]] || false
}
@test "clone a non-existent remote" {
dolt remote add test-remote http://localhost:50051/test-org/test-repo
cd "dolt-repo-clones"
run dolt clone foo/bar
[ "$status" -eq 1 ]
skip "Cloning a non-existant repository fails weirdly and leaves trash"
[ "$output" = "fatal: repository 'foo/bar' does not exist" ]
[[ ! "$output" =~ "permission denied" ]] || false
[ ! -d bar ]
}
@test "clone a different branch than master" {
dolt remote add test-remote http://localhost:50051/test-org/test-repo
dolt checkout -b test-branch
dolt sql <<SQL
CREATE TABLE test (
pk BIGINT NOT NULL COMMENT 'tag:0',
c1 BIGINT COMMENT 'tag:1',
c2 BIGINT COMMENT 'tag:2',
c3 BIGINT COMMENT 'tag:3',
c4 BIGINT COMMENT 'tag:4',
c5 BIGINT COMMENT 'tag:5',
PRIMARY KEY (pk)
);
SQL
dolt add test
dolt commit -m "test commit"
dolt push test-remote test-branch
cd "dolt-repo-clones"
run dolt clone -b test-branch http://localhost:50051/test-org/test-repo
[ "$status" -eq 0 ]
[[ "$output" =~ "cloning http://localhost:50051/test-org/test-repo" ]] || false
cd test-repo
run dolt branch
[ "$status" -eq 0 ]
[[ ! "$output" =~ "master" ]] || false
[[ "$output" =~ "test-branch" ]] || false
run dolt log
[ "$status" -eq 0 ]
[[ "$output" =~ "test commit" ]] || false
}
@test "call a clone's remote something other than origin" {
dolt remote add test-remote http://localhost:50051/test-org/test-repo
dolt sql <<SQL
CREATE TABLE test (
pk BIGINT NOT NULL COMMENT 'tag:0',
c1 BIGINT COMMENT 'tag:1',
c2 BIGINT COMMENT 'tag:2',
c3 BIGINT COMMENT 'tag:3',
c4 BIGINT COMMENT 'tag:4',
c5 BIGINT COMMENT 'tag:5',
PRIMARY KEY (pk)
);
SQL
dolt add test
dolt commit -m "test commit"
dolt push test-remote master
cd "dolt-repo-clones"
run dolt clone --remote test-remote http://localhost:50051/test-org/test-repo
[ "$status" -eq 0 ]
[[ "$output" =~ "cloning http://localhost:50051/test-org/test-repo" ]] || false
cd test-repo
run dolt log
[ "$status" -eq 0 ]
[[ "$output" =~ "test commit" ]] || false
run dolt remote -v
[ "$status" -eq 0 ]
[[ "$output" =~ "test-remote" ]] || false
[[ ! "$output" =~ "origin" ]] || false
}
@test "dolt fetch" {
dolt remote add test-remote http://localhost:50051/test-org/test-repo
dolt push test-remote master
run dolt fetch test-remote
[ "$status" -eq 0 ]
[ "$output" = "" ]
run dolt fetch test-remote refs/heads/master:refs/remotes/test-remote/master
[ "$status" -eq 0 ]
[ "$output" = "" ]
run dolt fetch poop refs/heads/master:refs/remotes/poop/master
[ "$status" -eq 1 ]
echo $output
[[ "$output" =~ "unknown remote" ]] || false
run dolt fetch test-remote refs/heads/master:refs/remotes/test-remote/poop
[ "$status" -eq 0 ]
[ "$output" = "" ]
run dolt branch -v -a
[ "$status" -eq 0 ]
[[ "$output" =~ "remotes/test-remote/poop" ]] || false
}
@test "dolt fetch with docs" {
# Initial commit of docs on remote
echo "initial-license" > LICENSE.md
echo "initial-readme" > README.md
dolt add .
dolt commit -m "initial doc commit"
dolt remote add test-remote http://localhost:50051/test-org/test-repo
dolt push test-remote master
run dolt fetch test-remote
[ "$status" -eq 0 ]
[ "$output" = "" ]
run cat README.md
[ "$status" -eq 0 ]
[[ "$output" =~ "initial-readme" ]] || false
run cat LICENSE.md
[ "$status" -eq 0 ]
[[ "$output" =~ "initial-license" ]] || false
# Clone the initial docs/repo into dolt-repo-clones/test-repo
cd "dolt-repo-clones"
run dolt clone http://localhost:50051/test-org/test-repo
cd test-repo
run cat LICENSE.md
[ "$status" -eq 0 ]
[[ "$output" =~ "initial-license" ]] || false
run cat README.md
[ "$status" -eq 0 ]
[[ "$output" =~ "initial-readme" ]] || false
# Change the docs
echo "dolt-repo-clones-license" > LICENSE.md
echo "dolt-repo-clones-readme" > README.md
dolt add .
dolt commit -m "dolt-repo-clones updated docs"
# Go back to original repo, and change the docs again
cd ../../
echo "initial-license-updated" > LICENSE.md
echo "initial-readme-updated" > README.md
dolt add .
dolt commit -m "update initial doc values in test-org/test-repo"
# Go back to dolt-repo-clones/test-repo and fetch the test-remote
cd dolt-repo-clones/test-repo
run dolt fetch test-remote
run cat LICENSE.md
[ "$status" -eq 0 ]
[[ "$output" =~ "dolt-repo-clones-license" ]] || false
run cat README.md
[ "$status" -eq 0 ]
[[ "$output" =~ "dolt-repo-clones-readme" ]] || false
}
@test "dolt merge with origin/master syntax." {
dolt remote add test-remote http://localhost:50051/test-org/test-repo
dolt push test-remote master
dolt fetch test-remote
cd "dolt-repo-clones"
dolt clone http://localhost:50051/test-org/test-repo
cd ..
dolt sql <<SQL
CREATE TABLE test (
pk BIGINT NOT NULL COMMENT 'tag:0',
c1 BIGINT COMMENT 'tag:1',
c2 BIGINT COMMENT 'tag:2',
c3 BIGINT COMMENT 'tag:3',
c4 BIGINT COMMENT 'tag:4',
c5 BIGINT COMMENT 'tag:5',
PRIMARY KEY (pk)
);
SQL
dolt add test
dolt commit -m "test commit"
dolt push test-remote master
cd "dolt-repo-clones/test-repo"
run dolt log
[ "$status" -eq 0 ]
[[ ! "$output" =~ "test commit" ]] || false
run dolt merge origin/master
[ "$status" -eq 0 ]
# This needs to say up-to-date like the skipped test above
# [[ "$output" =~ "up to date" ]]
run dolt fetch
[ "$status" -eq 0 ]
run dolt merge origin/master
[ "$status" -eq 0 ]
[[ "$output" =~ "Fast-forward" ]]
run dolt log
[ "$status" -eq 0 ]
[[ "$output" =~ "test commit" ]] || false
}
@test "dolt fetch and merge with remotes/origin/master syntax" {
dolt remote add test-remote http://localhost:50051/test-org/test-repo
dolt push test-remote master
cd "dolt-repo-clones"
dolt clone http://localhost:50051/test-org/test-repo
cd ..
dolt sql <<SQL
CREATE TABLE test (
pk BIGINT NOT NULL COMMENT 'tag:0',
c1 BIGINT COMMENT 'tag:1',
c2 BIGINT COMMENT 'tag:2',
c3 BIGINT COMMENT 'tag:3',
c4 BIGINT COMMENT 'tag:4',
c5 BIGINT COMMENT 'tag:5',
PRIMARY KEY (pk)
);
SQL
dolt add test
dolt commit -m "test commit"
dolt push test-remote master
cd "dolt-repo-clones/test-repo"
skip "This remotes/origin/master syntax no longer works but works on git"
run dolt merge remotes/origin/master
[ "$status" -eq 0 ]
# This needs to say up-to-date like the skipped test above
# [[ "$output" =~ "up to date" ]]
dolt fetch origin master
[ "$status" -eq 0 ]
run dolt merge remotes/origin/master
[ "$status" -eq 0 ]
[[ "$output" =~ "Fast-forward" ]]
}
@test "try to push a remote that is behind tip" {
dolt remote add test-remote http://localhost:50051/test-org/test-repo
dolt push test-remote master
cd "dolt-repo-clones"
dolt clone http://localhost:50051/test-org/test-repo
cd ..
dolt sql <<SQL
CREATE TABLE test (
pk BIGINT NOT NULL COMMENT 'tag:0',
c1 BIGINT COMMENT 'tag:1',
c2 BIGINT COMMENT 'tag:2',
c3 BIGINT COMMENT 'tag:3',
c4 BIGINT COMMENT 'tag:4',
c5 BIGINT COMMENT 'tag:5',
PRIMARY KEY (pk)
);
SQL
dolt add test
dolt commit -m "test commit"
dolt push test-remote master
cd "dolt-repo-clones/test-repo"
run dolt push origin master
[ "$status" -eq 0 ]
[[ "$output" =~ "Everything up-to-date" ]] || false
dolt fetch
run dolt push origin master
[ "$status" -eq 1 ]
[[ "$output" =~ "tip of your current branch is behind" ]] || false
}
@test "generate a merge with no conflict with a remote branch" {
dolt remote add test-remote http://localhost:50051/test-org/test-repo
dolt push test-remote master
cd "dolt-repo-clones"
dolt clone http://localhost:50051/test-org/test-repo
cd ..
dolt sql <<SQL
CREATE TABLE test (
pk BIGINT NOT NULL COMMENT 'tag:0',
c1 BIGINT COMMENT 'tag:1',
c2 BIGINT COMMENT 'tag:2',
c3 BIGINT COMMENT 'tag:3',
c4 BIGINT COMMENT 'tag:4',
c5 BIGINT COMMENT 'tag:5',
PRIMARY KEY (pk)
);
SQL
dolt add test
dolt commit -m "test commit"
dolt push test-remote master
cd "dolt-repo-clones/test-repo"
dolt sql <<SQL
CREATE TABLE test2 (
pk BIGINT NOT NULL COMMENT 'tag:10',
c1 BIGINT COMMENT 'tag:11',
c2 BIGINT COMMENT 'tag:12',
c3 BIGINT COMMENT 'tag:13',
c4 BIGINT COMMENT 'tag:14',
c5 BIGINT COMMENT 'tag:15',
PRIMARY KEY (pk)
);
SQL
dolt add test2
dolt commit -m "another test commit"
run dolt pull origin
[ "$status" -eq 0 ]
[[ "$output" =~ "Updating" ]] || false
}
@test "generate a merge with a conflict with a remote branch" {
dolt remote add test-remote http://localhost:50051/test-org/test-repo
dolt sql <<SQL
CREATE TABLE test (
pk BIGINT NOT NULL COMMENT 'tag:0',
c1 BIGINT COMMENT 'tag:1',
c2 BIGINT COMMENT 'tag:2',
c3 BIGINT COMMENT 'tag:3',
c4 BIGINT COMMENT 'tag:4',
c5 BIGINT COMMENT 'tag:5',
PRIMARY KEY (pk)
);
SQL
dolt add test
dolt commit -m "created table"
dolt push test-remote master
cd "dolt-repo-clones"
dolt clone http://localhost:50051/test-org/test-repo
cd ..
dolt sql -q "insert into test values (0, 0, 0, 0, 0, 0)"
dolt add test
dolt commit -m "row to generate conflict"
dolt push test-remote master
cd "dolt-repo-clones/test-repo"
dolt sql -q "insert into test values (0, 1, 1, 1, 1, 1)"
dolt add test
dolt commit -m "conflicting row"
run dolt pull origin
[ "$status" -eq 0 ]
[[ "$output" =~ "CONFLICT" ]]
dolt conflicts resolve test --ours
dolt add test
dolt commit -m "Fixed conflicts"
run dolt push origin master
cd ../../
dolt pull test-remote
run dolt log
[[ "$output" =~ "Fixed conflicts" ]] || false
}
@test "clone sets your current branch appropriately" {
dolt remote add test-remote http://localhost:50051/test-org/test-repo
dolt sql <<SQL
CREATE TABLE test (
pk BIGINT NOT NULL COMMENT 'tag:0',
c1 BIGINT COMMENT 'tag:1',
c2 BIGINT COMMENT 'tag:2',
c3 BIGINT COMMENT 'tag:3',
c4 BIGINT COMMENT 'tag:4',
c5 BIGINT COMMENT 'tag:5',
PRIMARY KEY (pk)
);
SQL
dolt add test
dolt commit -m "test commit"
dolt checkout -b aaa
dolt checkout -b zzz
dolt push test-remote aaa
dolt push test-remote zzz
cd "dolt-repo-clones"
dolt clone http://localhost:50051/test-org/test-repo
cd test-repo
# master hasn't been pushed so expect zzz to be the current branch and the string master should not be present
run dolt branch
[ "$status" -eq 0 ]
[[ "$output" =~ "aaa" ]] || false
[[ "$output" =~ "* zzz" ]] || false
[[ ! "$output" =~ "master" ]] || false
cd ../..
dolt push test-remote master
cd "dolt-repo-clones"
dolt clone http://localhost:50051/test-org/test-repo test-repo2
cd test-repo2
# master pushed so it should be the current branch.
run dolt branch
[ "$status" -eq 0 ]
[[ "$output" =~ "aaa" ]] || false
[[ "$output" =~ "zzz" ]] || false
[[ "$output" =~ "* master" ]] || false
}
@test "dolt pull onto a dirty working set fails" {
dolt remote add test-remote http://localhost:50051/test-org/test-repo
dolt sql <<SQL
CREATE TABLE test (
pk BIGINT NOT NULL COMMENT 'tag:0',
c1 BIGINT COMMENT 'tag:1',
c2 BIGINT COMMENT 'tag:2',
c3 BIGINT COMMENT 'tag:3',
c4 BIGINT COMMENT 'tag:4',
c5 BIGINT COMMENT 'tag:5',
PRIMARY KEY (pk)
);
SQL
dolt add test
dolt commit -m "created table"
dolt push test-remote master
cd "dolt-repo-clones"
dolt clone http://localhost:50051/test-org/test-repo
cd ..
dolt sql -q "insert into test values (0, 0, 0, 0, 0, 0)"
dolt add test
dolt commit -m "row to generate conflict"
dolt push test-remote master
cd "dolt-repo-clones/test-repo"
dolt sql -q "insert into test values (0, 1, 1, 1, 1, 1)"
run dolt pull origin
[ "$status" -ne 0 ]
[[ "$output" =~ "error: Your local changes to the following tables would be overwritten by merge:" ]] || false
[[ "$output" =~ "test" ]] || false
[[ "$output" =~ "Please commit your changes before you merge." ]] || false
}
@test "force push to master" {
dolt remote add test-remote http://localhost:50051/test-org/test-repo
dolt push test-remote master
cd "dolt-repo-clones"
dolt clone http://localhost:50051/test-org/test-repo
cd ..
dolt sql <<SQL
CREATE TABLE test (
pk BIGINT NOT NULL COMMENT 'tag:0',
c1 BIGINT COMMENT 'tag:1',
c2 BIGINT COMMENT 'tag:2',
c3 BIGINT COMMENT 'tag:3',
c4 BIGINT COMMENT 'tag:4',
c5 BIGINT COMMENT 'tag:5',
PRIMARY KEY (pk)
);
SQL
dolt add test
dolt commit -m "test commit"
dolt push test-remote master
cd "dolt-repo-clones/test-repo"
dolt sql <<SQL
CREATE TABLE other (
pk BIGINT NOT NULL COMMENT 'tag:0',
c1 BIGINT COMMENT 'tag:1',
c2 BIGINT COMMENT 'tag:2',
c3 BIGINT COMMENT 'tag:3',
c4 BIGINT COMMENT 'tag:4',
c5 BIGINT COMMENT 'tag:5',
PRIMARY KEY (pk)
);
SQL
dolt add other
dolt commit -m "added other table"
dolt fetch
run dolt push origin master
[ "$status" -eq 1 ]
[[ "$output" =~ "tip of your current branch is behind" ]] || false
dolt push -f master
run dolt push -f origin master
[ "$status" -eq 0 ]
}
@test "force fetch from master" {
dolt remote add test-remote http://localhost:50051/test-org/test-repo
dolt push test-remote master
cd "dolt-repo-clones"
dolt clone http://localhost:50051/test-org/test-repo
cd ..
dolt sql <<SQL
CREATE TABLE test (
pk BIGINT NOT NULL COMMENT 'tag:0',
c1 BIGINT COMMENT 'tag:1',
c2 BIGINT COMMENT 'tag:2',
c3 BIGINT COMMENT 'tag:3',
c4 BIGINT COMMENT 'tag:4',
c5 BIGINT COMMENT 'tag:5',
PRIMARY KEY (pk)
);
SQL
dolt add test
dolt commit -m "test commit"
dolt push test-remote master
cd "dolt-repo-clones/test-repo"
dolt sql <<SQL
CREATE TABLE other (
pk BIGINT NOT NULL COMMENT 'tag:10',
c1 BIGINT COMMENT 'tag:11',
c2 BIGINT COMMENT 'tag:12',
c3 BIGINT COMMENT 'tag:13',
c4 BIGINT COMMENT 'tag:14',
c5 BIGINT COMMENT 'tag:15',
PRIMARY KEY (pk)
);
SQL
dolt add other
dolt commit -m "added other table"
dolt fetch
dolt push -f origin master
cd ../../
run dolt fetch test-remote
[ "$status" -ne 0 ]
run dolt pull
[ "$status" -ne 0 ]
run dolt fetch -f test-remote
[ "$status" -eq 0 ]
dolt pull
[ "$status" -eq 0 ]
}