mirror of
https://github.com/dolthub/dolt.git
synced 2026-05-21 19:49:05 -05:00
add driver like env test
This commit is contained in:
@@ -2201,3 +2201,35 @@ func TestBranchActivity(t *testing.T) {
|
||||
defer h.Close()
|
||||
RunBranchActivityTests(t, h)
|
||||
}
|
||||
|
||||
// TestDriverExecution verifies that queries work in dolt driver, where the MySQLDb is not initialized.
|
||||
func TestDriverExecution(t *testing.T) {
|
||||
h := newDoltHarness(t)
|
||||
defer h.Close()
|
||||
|
||||
engine, err := h.NewEngine(t)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer engine.Close()
|
||||
|
||||
// Simulate driver environment. The MySQLDb is initialized but with no users (not even root). The context user is
|
||||
// "root" still though. This mimics the dolthub/driver initialization of the engine (no PrivFilePath provided).
|
||||
engine.EngineAnalyzer().Catalog.MySQLDb = mysql_db.CreateEmptyMySQLDb()
|
||||
ctx := enginetest.NewContextWithClient(h, sql.Client{
|
||||
User: "root",
|
||||
Address: "localhost",
|
||||
})
|
||||
|
||||
q := "call dolt_backup('add', 'backup1', 'file:///tmp/backup1');"
|
||||
enginetest.TestQueryWithContext(t, ctx, engine, h, q, []sql.Row{{0}}, nil, nil, nil)
|
||||
|
||||
q = "select name from dolt_backups where name = 'backup1'"
|
||||
enginetest.TestQueryWithContext(t, ctx, engine, h, q, []sql.Row{{"backup1"}}, nil, nil, nil)
|
||||
|
||||
q = "call dolt_backup('sync-url', 'file:///tmp/backup_sync_url');"
|
||||
enginetest.TestQueryWithContext(t, ctx, engine, h, q, []sql.Row{{0}}, nil, nil, nil)
|
||||
|
||||
q = "call dolt_backup('remove', 'backup1');"
|
||||
enginetest.TestQueryWithContext(t, ctx, engine, h, q, []sql.Row{{0}}, nil, nil, nil)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user