@@ -899,10 +899,144 @@ func TestDoltCommit(t *testing.T) {
899899 })
900900}
901901
902+ var simpleConflictResolveSetupScript = []string {
903+ "CREATE TABLE t_simple (pk INT4 PRIMARY KEY, v1 INT4);" ,
904+ "INSERT INTO t_simple VALUES (1, 1);" ,
905+ "SELECT DOLT_COMMIT('-Am', 'initial')" ,
906+ "SELECT DOLT_BRANCH('other');" ,
907+ "INSERT INTO t_simple VALUES (2, 2);" ,
908+ "SELECT DOLT_COMMIT('-Am', 'second row on main')" ,
909+ "SELECT DOLT_CHECKOUT('other');" ,
910+ "INSERT INTO t_simple VALUES (2, 3);" ,
911+ "SELECT DOLT_COMMIT('-Am', 'conflicted row on other')" ,
912+ "SELECT DOLT_CHECKOUT('main');" ,
913+ }
914+
902915// TestDoltConflictsResolve includes a multitude of items to ensure that we properly handle conflict resolution for all
903916// of them.
904917func TestDoltConflictsResolve (t * testing.T ) {
905918 RunScripts (t , []ScriptTest {
919+ {
920+ Name : "Simple conflicts resolve all using --ours" ,
921+ SetUpScript : simpleConflictResolveSetupScript ,
922+ Assertions : []ScriptTestAssertion {
923+ {
924+ Query : "BEGIN;" ,
925+ Expected : []sql.Row {},
926+ },
927+ {
928+ Query : "SELECT DOLT_MERGE('other', '--no-ff');" ,
929+ Expected : []sql.Row {{`{0,1,"conflicts found"}` }},
930+ },
931+ {
932+ Query : "SELECT * FROM dolt_conflicts;" ,
933+ Expected : []sql.Row {{"t_simple" , 1 }},
934+ },
935+ {
936+ Query : "SELECT DOLT_CONFLICTS_RESOLVE('--ours', '.');" ,
937+ Expected : []sql.Row {{"{0}" }},
938+ },
939+ {
940+ Query : "SELECT DOLT_COMMIT('-Am', 'commit merge');" ,
941+ SkipResultsCheck : true ,
942+ },
943+ {
944+ Query : `SELECT * FROM t_simple;` ,
945+ Expected : []sql.Row {{1 , 1 }, {2 , 2 }},
946+ },
947+ },
948+ },
949+ {
950+ Name : "Simple conflicts resolve all using --theirs" ,
951+ SetUpScript : simpleConflictResolveSetupScript ,
952+ Assertions : []ScriptTestAssertion {
953+ {
954+ Query : "BEGIN;" ,
955+ Expected : []sql.Row {},
956+ },
957+ {
958+ Query : "SELECT DOLT_MERGE('other', '--no-ff');" ,
959+ Expected : []sql.Row {{`{0,1,"conflicts found"}` }},
960+ },
961+ {
962+ Query : "SELECT * FROM dolt_conflicts;" ,
963+ Expected : []sql.Row {{"t_simple" , 1 }},
964+ },
965+ {
966+ Query : "SELECT DOLT_CONFLICTS_RESOLVE('--theirs', '.');" ,
967+ Expected : []sql.Row {{"{0}" }},
968+ },
969+ {
970+ Query : "SELECT DOLT_COMMIT('-Am', 'commit merge');" ,
971+ SkipResultsCheck : true ,
972+ },
973+ {
974+ Query : `SELECT * FROM t_simple;` ,
975+ Expected : []sql.Row {{1 , 1 }, {2 , 3 }},
976+ },
977+ },
978+ },
979+ {
980+ Name : "Simple conflicts resolve table using --ours" ,
981+ SetUpScript : simpleConflictResolveSetupScript ,
982+ Assertions : []ScriptTestAssertion {
983+ {
984+ Query : "BEGIN;" ,
985+ Expected : []sql.Row {},
986+ },
987+ {
988+ Query : "SELECT DOLT_MERGE('other', '--no-ff');" ,
989+ Expected : []sql.Row {{`{0,1,"conflicts found"}` }},
990+ },
991+ {
992+ Query : "SELECT * FROM dolt_conflicts;" ,
993+ Expected : []sql.Row {{"t_simple" , 1 }},
994+ },
995+ {
996+ Query : "SELECT DOLT_CONFLICTS_RESOLVE('--ours', 't_simple');" ,
997+ Expected : []sql.Row {{"{0}" }},
998+ },
999+ {
1000+ Query : "SELECT DOLT_COMMIT('-Am', 'commit merge');" ,
1001+ SkipResultsCheck : true ,
1002+ },
1003+ {
1004+ Query : `SELECT * FROM t_simple;` ,
1005+ Expected : []sql.Row {{1 , 1 }, {2 , 2 }},
1006+ },
1007+ },
1008+ },
1009+ {
1010+ Name : "Simple conflicts resolve table using --theirs" ,
1011+ Skip : true ,
1012+ SetUpScript : simpleConflictResolveSetupScript ,
1013+ Assertions : []ScriptTestAssertion {
1014+ {
1015+ Query : "BEGIN;" ,
1016+ Expected : []sql.Row {},
1017+ },
1018+ {
1019+ Query : "SELECT DOLT_MERGE('other', '--no-ff');" ,
1020+ Expected : []sql.Row {{`{0,1,"conflicts found"}` }},
1021+ },
1022+ {
1023+ Query : "SELECT * FROM dolt_conflicts;" ,
1024+ Expected : []sql.Row {{"t_simple" , 1 }},
1025+ },
1026+ {
1027+ Query : "SELECT DOLT_CONFLICTS_RESOLVE('--theirs', 't_simple');" ,
1028+ Expected : []sql.Row {{"{0}" }},
1029+ },
1030+ {
1031+ Query : "SELECT DOLT_COMMIT('-Am', 'commit merge');" ,
1032+ SkipResultsCheck : true ,
1033+ },
1034+ {
1035+ Query : `SELECT * FROM t_simple;` ,
1036+ Expected : []sql.Row {{1 , 1 }, {2 , 3 }},
1037+ },
1038+ },
1039+ },
9061040 {
9071041 Name : "Resolve all using --ours" ,
9081042 Skip : true , // TODO: attempting a merge with generated columns causes a panic
0 commit comments