Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
refactor: add temp dir as data dir for external pg in test (#1385)
Yilong Li264c03a566f4
diff --git a/bin/server/cmd/profile_dev.go b/bin/server/cmd/profile_dev.goindex 2a89f3abd2..3d0fe8763b 100644--- a/bin/server/cmd/profile_dev.go+++ b/bin/server/cmd/profile_dev.go@@ -54,12 +54,13 @@ func GetTestProfile(dataDir string, port int) server.Profile {// GetTestProfileWithExternalPg will return a profile for testing with external Postgres.// We require port as an argument of GetTestProfile so that test can run in parallel in different ports,// pgURL for connect to Postgres.-func GetTestProfileWithExternalPg(port int, pgUser string, pgURL string) server.Profile {+func GetTestProfileWithExternalPg(dataDir string, port int, pgUser string, pgURL string) server.Profile {return server.Profile{Mode: common.ReleaseModeDev,BackendHost: flags.host,BackendPort: port,PgUser: pgUser,+ DataDir: dataDir,DemoDataDir: fmt.Sprintf("demo/%s", common.ReleaseModeDev),BackupRunnerInterval: 10 * time.Second,PgURL: pgURL,diff --git a/tests/external_pg_test.go b/tests/external_pg_test.goindex d22743f9db..a443500708 100644--- a/tests/external_pg_test.go+++ b/tests/external_pg_test.go@@ -57,13 +57,14 @@ func TestBootWithExternalPg(t *testing.T) {a.NoError(err)defer func() {if err = externalPg.Destroy(); err != nil {- fmt.Printf("cannot destroy pginstance, error: %s", err.Error())+ fmt.Printf("cannot destroy postgres instance, error: %s", err.Error())t.FailNow()}}()ctl := &controller{}- err = ctl.StartServerWithExternalPg(ctx, serverPort, externalPg.pgUser, externalPg.pgURL)+ dataTmpDir := t.TempDir()+ err = ctl.StartServerWithExternalPg(ctx, dataTmpDir, serverPort, externalPg.pgUser, externalPg.pgURL)a.NoError(err)defer ctl.Close(ctx)}diff --git a/tests/tests.go b/tests/tests.goindex f96c9a8037..c0e33247d2 100644--- a/tests/tests.go+++ b/tests/tests.go@@ -143,14 +143,14 @@ func getTestPort(testName string) int {}// StartServerWithExternalPg starts the main server with external Postgres.-func (ctl *controller) StartServerWithExternalPg(ctx context.Context, port int, pgUser, pgURL string) error {+func (ctl *controller) StartServerWithExternalPg(ctx context.Context, dataDir string, port int, pgUser, pgURL string) error {logger, lvl, err := cmd.GetLogger()if err != nil {return fmt.Errorf("failed to get logger, error: %w", err)}defer logger.Sync()- profile := cmd.GetTestProfileWithExternalPg(port, pgUser, pgURL)+ profile := cmd.GetTestProfileWithExternalPg(dataDir, port, pgUser, pgURL)ctl.server, err = server.NewServer(ctx, profile, logger, lvl)if err != nil {return err