From 215fa309e6d69aa517fb98f786f4077c22fad992 Mon Sep 17 00:00:00 2001 From: Elian Date: Mon, 23 Jun 2025 12:15:42 -0700 Subject: [PATCH] add dolt queries test --- .../sqle/enginetest/dolt_engine_tests.go | 1 + .../doltcore/sqle/enginetest/dolt_queries.go | 44 +++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/go/libraries/doltcore/sqle/enginetest/dolt_engine_tests.go b/go/libraries/doltcore/sqle/enginetest/dolt_engine_tests.go index 85b04d2378..bd83a559df 100755 --- a/go/libraries/doltcore/sqle/enginetest/dolt_engine_tests.go +++ b/go/libraries/doltcore/sqle/enginetest/dolt_engine_tests.go @@ -1026,6 +1026,7 @@ func RunDoltCheckoutTests(t *testing.T, h DoltEnginetestHarness) { func() { h := h.NewHarness(t) defer h.Close() + h.UseLocalFileSystem() enginetest.TestScript(t, h, script) }() } diff --git a/go/libraries/doltcore/sqle/enginetest/dolt_queries.go b/go/libraries/doltcore/sqle/enginetest/dolt_queries.go index 626702d6a0..db7abf3e0c 100644 --- a/go/libraries/doltcore/sqle/enginetest/dolt_queries.go +++ b/go/libraries/doltcore/sqle/enginetest/dolt_queries.go @@ -3392,6 +3392,50 @@ var DoltCheckoutScripts = []queries.ScriptTest{ }, }, }, + { + Name: "dolt_checkout disambiguation with remote tracking branch and table", + SetUpScript: []string{ + "call dolt_remote('add','origin','file://../remote-repo');", + "create table feature (id int primary key, value int);", + "insert into feature values (1, 100);", + "call dolt_add('.');", + "call dolt_commit('-m', 'Add feature table');", + "call dolt_checkout('-b', 'feature');", + "insert into feature values (2, 200);", + "call dolt_add('.');", + "call dolt_commit('-m', 'Add row to feature table');", + "call dolt_push('origin', 'feature');", + "call dolt_checkout('main');", + "update feature set value = 101 where id = 1;", + "call dolt_branch('-D', 'feature');", // Remove local branch to force remote tracking branch ambiguity + }, + Assertions: []queries.ScriptTestAssertion{ + { + Query: "call dolt_checkout('--', 'feature');", + Expected: []sql.Row{{0, ""}}, + }, + { + Query: "select * from feature order by id;", + Expected: []sql.Row{{1, 100}}, + }, + { + Query: "call dolt_checkout('feature')", + ExpectedErrStr: "'feature' could be both a local table and a tracking branch.\nPlease use -- to disambiguate.", + }, + { + Query: "call dolt_checkout('feature', '--');", + Expected: []sql.Row{{0, "Switched to branch 'feature'\nbranch 'feature' set up to track 'origin/feature'."}}, + }, + { + Query: "select active_branch();", + Expected: []sql.Row{{"feature"}}, + }, + { + Query: "select * from feature order by id;", + Expected: []sql.Row{{1, 100}, {2, 200}}, + }, + }, + }, } var DoltCheckoutReadOnlyScripts = []queries.ScriptTest{