Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: use SQLite instead of MySQL for TestWildcardInVCSFilePathTemplate for saving some test time (#2911)

Danny Xu765e31ee2ac0
diff --git a/tests/project_test.go b/tests/project_test.go
index 8766241b2f..062e9ddd15 100644
--- a/tests/project_test.go
+++ b/tests/project_test.go
@@ -4,7 +4,6 @@ import (
"context"
"encoding/json"
"fmt"
- "strconv"
"testing"
"github.com/stretchr/testify/require"
@@ -13,7 +12,6 @@ import (
"github.com/bytebase/bytebase/api"
"github.com/bytebase/bytebase/common/log"
"github.com/bytebase/bytebase/plugin/db"
- resourcemysql "github.com/bytebase/bytebase/resources/mysql"
"github.com/bytebase/bytebase/tests/fake"
)
@@ -32,23 +30,21 @@ func TestArchiveProject(t *testing.T) {
err = ctl.setLicense()
a.NoError(err)
- mysqlPort := serverPort + 1
- _, stopInstance := resourcemysql.SetupTestInstance(t, mysqlPort)
- defer stopInstance()
+ instanceRootDir := t.TempDir()
+ instanceName := "testInstance1"
+ instanceDir, err := ctl.provisionSQLiteInstance(instanceRootDir, instanceName)
+ a.NoError(err)
environments, err := ctl.getEnvironments()
a.NoError(err)
prodEnvironment, err := findEnvironment(environments, "Prod")
a.NoError(err)
- connCfg := getMySQLConnectionConfig(strconv.Itoa(mysqlPort), "")
instance, err := ctl.addInstance(api.InstanceCreate{
EnvironmentID: prodEnvironment.ID,
Name: "test",
- Engine: db.MySQL,
- Host: connCfg.Host,
- Port: connCfg.Port,
- Username: connCfg.Username,
+ Engine: db.SQLite,
+ Host: instanceDir,
})
a.NoError(err)
@@ -60,7 +56,7 @@ func TestArchiveProject(t *testing.T) {
})
a.NoError(err)
- databaseName := "db"
+ databaseName := "db1"
err = ctl.createDatabase(project, instance, databaseName, "", nil)
a.NoError(err)
diff --git a/tests/schema_update_test.go b/tests/schema_update_test.go
index 521ef26a1f..a77616c13d 100644
--- a/tests/schema_update_test.go
+++ b/tests/schema_update_test.go
@@ -18,7 +18,6 @@ import (
"github.com/bytebase/bytebase/plugin/vcs"
"github.com/bytebase/bytebase/plugin/vcs/github"
"github.com/bytebase/bytebase/plugin/vcs/gitlab"
- resourcemysql "github.com/bytebase/bytebase/resources/mysql"
"github.com/bytebase/bytebase/resources/postgres"
"github.com/bytebase/bytebase/tests/fake"
)
@@ -954,7 +953,7 @@ ALTER TABLE ONLY public.users
func TestWildcardInVCSFilePathTemplate(t *testing.T) {
branchFilter := "feature/foo"
- dbName := "db"
+ dbName := "db1"
externalID := "121"
repoFullPath := "test/wildcard"
@@ -1189,7 +1188,6 @@ func TestWildcardInVCSFilePathTemplate(t *testing.T) {
t.Parallel()
port := getTestPort(t.Name())
- mysqlPort := port + 3
a := require.New(t)
ctx := context.Background()
ctl := &controller{}
@@ -1251,17 +1249,15 @@ func TestWildcardInVCSFilePathTemplate(t *testing.T) {
})
a.NoError(err)
// Provision an instance.
- instanceName := "testInstance"
- _, stopInstance := resourcemysql.SetupTestInstance(t, mysqlPort)
- defer stopInstance()
- connCfg := getMySQLConnectionConfig(strconv.Itoa(mysqlPort), "")
+ instanceRootDir := t.TempDir()
+ instanceName := "testInstance1"
+ instanceDir, err := ctl.provisionSQLiteInstance(instanceRootDir, instanceName)
+ a.NoError(err)
instance, err := ctl.addInstance(api.InstanceCreate{
EnvironmentID: environment.ID,
Name: instanceName,
- Engine: db.MySQL,
- Host: connCfg.Host,
- Port: connCfg.Port,
- Username: connCfg.Username,
+ Engine: db.SQLite,
+ Host: instanceDir,
})
a.NoError(err)