Skip to content

Commit 8f98000

Browse files
authored
Merge pull request #1779 from dolthub/taylor/conflict-resolve
Add simple tests for dolt_conflicts_resolve
2 parents 1f9849e + 434aaaf commit 8f98000

File tree

3 files changed

+140
-6
lines changed

3 files changed

+140
-6
lines changed

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ require (
66
github.com/PuerkitoBio/goquery v1.8.1
77
github.com/cockroachdb/apd/v2 v2.0.3-0.20200518165714-d020e156310a
88
github.com/cockroachdb/errors v1.7.5
9-
github.com/dolthub/dolt/go v0.40.5-0.20250821213345-14be1652345c
9+
github.com/dolthub/dolt/go v0.40.5-0.20250826135702-2e2b8e9c317a
1010
github.com/dolthub/eventsapi_schema v0.0.0-20250725194025-a087efa1ee55
1111
github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2
1212
github.com/dolthub/go-icu-regex v0.0.0-20250820171420-f2b78f56ce9f
13-
github.com/dolthub/go-mysql-server v0.20.1-0.20250820230411-3d7fa0e18554
13+
github.com/dolthub/go-mysql-server v0.20.1-0.20250825220247-28daf87bfe0e
1414
github.com/dolthub/sqllogictest/go v0.0.0-20240618184124-ca47f9354216
1515
github.com/dolthub/vitess v0.0.0-20250814204310-c749d213f235
1616
github.com/fatih/color v1.13.0

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,8 @@ github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5Xh
248248
github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
249249
github.com/dolthub/aws-sdk-go-ini-parser v0.0.0-20250305001723-2821c37f6c12 h1:IdqX7J8vi/Kn3T3Ee0VzqnLqwFmgA2hr8WZETPcQjfM=
250250
github.com/dolthub/aws-sdk-go-ini-parser v0.0.0-20250305001723-2821c37f6c12/go.mod h1:rN7X8BHwkjPcfMQQ2QTAq/xM3leUSGLfb+1Js7Y6TVo=
251-
github.com/dolthub/dolt/go v0.40.5-0.20250821213345-14be1652345c h1:zSOHOU3lBdY+FSKAhd04XSsXlrZXL5ZAMFSMUMqGlEQ=
252-
github.com/dolthub/dolt/go v0.40.5-0.20250821213345-14be1652345c/go.mod h1:bno+IQ3aElzFK2n09FeSzvgJeQjNeHlUYYrVPs+Isdg=
251+
github.com/dolthub/dolt/go v0.40.5-0.20250826135702-2e2b8e9c317a h1:ZMMgHcZ5Sjz00KqKI1yoDAeCKnXrlkqoCZMhYhBKryo=
252+
github.com/dolthub/dolt/go v0.40.5-0.20250826135702-2e2b8e9c317a/go.mod h1:kXaMm1siZhQPl4OPeqO+/G0wtx5FIh6Pb4tWtEr9P+s=
253253
github.com/dolthub/eventsapi_schema v0.0.0-20250725194025-a087efa1ee55 h1:LdtiPD8IJ+M2XckvfQ/aLG34lET1shz+WMccGBhZRLM=
254254
github.com/dolthub/eventsapi_schema v0.0.0-20250725194025-a087efa1ee55/go.mod h1:CoDLfgPqHyBtth0Cp+fi/CmC4R81zJNX4wPjShdZ+Bw=
255255
github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2 h1:u3PMzfF8RkKd3lB9pZ2bfn0qEG+1Gms9599cr0REMww=
@@ -258,8 +258,8 @@ github.com/dolthub/fslock v0.0.3 h1:iLMpUIvJKMKm92+N1fmHVdxJP5NdyDK5bK7z7Ba2s2U=
258258
github.com/dolthub/fslock v0.0.3/go.mod h1:QWql+P17oAAMLnL4HGB5tiovtDuAjdDTPbuqx7bYfa0=
259259
github.com/dolthub/go-icu-regex v0.0.0-20250820171420-f2b78f56ce9f h1:oSA8CptGeCEdTdD9LFtv8x4juDfdaLKsx1eocyaj1bE=
260260
github.com/dolthub/go-icu-regex v0.0.0-20250820171420-f2b78f56ce9f/go.mod h1:kpsRG+a196Y69zsAFL0RkQICII9a571lcaxhvQnmrdY=
261-
github.com/dolthub/go-mysql-server v0.20.1-0.20250820230411-3d7fa0e18554 h1:c0940a4L6FaByHYbZCVungNfIDGjybJtvUlkXKiI6f0=
262-
github.com/dolthub/go-mysql-server v0.20.1-0.20250820230411-3d7fa0e18554/go.mod h1:2kd3E7pEmjYEDBgdd0CtZGyXR/lvKC5RlDeTNHAV6VI=
261+
github.com/dolthub/go-mysql-server v0.20.1-0.20250825220247-28daf87bfe0e h1:9f0YFTi/CKw2MUnL67RQMAHDHOAgziP2vS5RH3wTaN0=
262+
github.com/dolthub/go-mysql-server v0.20.1-0.20250825220247-28daf87bfe0e/go.mod h1:2kd3E7pEmjYEDBgdd0CtZGyXR/lvKC5RlDeTNHAV6VI=
263263
github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63 h1:OAsXLAPL4du6tfbBgK0xXHZkOlos63RdKYS3Sgw/dfI=
264264
github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63/go.mod h1:lV7lUeuDhH5thVGDCKXbatwKy2KW80L4rMT46n+Y2/Q=
265265
github.com/dolthub/ishell v0.0.0-20240701202509-2b217167d718 h1:lT7hE5k+0nkBdj/1UOSFwjWpNxf+LCApbRHgnCA17XE=

testing/go/dolt_functions_test.go

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
904917
func 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

Comments
 (0)