lab5 done
This commit is contained in:
@@ -60,7 +60,7 @@ func TestIntegration(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer pool.Close()
|
||||
runGoose := func(t *testing.T, command string) {
|
||||
runGoose := func(t *testing.T, command string, params ...string) {
|
||||
t.Helper()
|
||||
migrationDir := os.Getenv("GOOSE_MIGRATION_DIR")
|
||||
if migrationDir == "" {
|
||||
@@ -73,7 +73,8 @@ func TestIntegration(t *testing.T) {
|
||||
connection.RawQuery = url.Values{"sslmode": {"disable"}, "search_path": {schema}, "connect_timeout": {"5"}}.Encode()
|
||||
commandCtx, cancel := context.WithTimeout(ctx, 45*time.Second)
|
||||
defer cancel()
|
||||
commandExec := exec.CommandContext(commandCtx, "goose", "-env", "/dev/null", "-dir", migrationDir, "-timeout", "30s", command)
|
||||
args := append([]string{"-env", "/dev/null", "-dir", migrationDir, "-timeout", "30s", command}, params...)
|
||||
commandExec := exec.CommandContext(commandCtx, "goose", args...)
|
||||
commandExec.Env = append(os.Environ(), "GOOSE_DRIVER=postgres", "GOOSE_DBSTRING="+connection.String(), "PGPASSWORD="+cfg.PostgresPassword)
|
||||
output, err := commandExec.CombinedOutput()
|
||||
if err != nil {
|
||||
@@ -260,6 +261,8 @@ func TestIntegration(t *testing.T) {
|
||||
if err = pool.QueryRow(ctx, digestSQL).Scan(&before); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// Model the actual lab4 physical schema before adopting its legacy journal.
|
||||
runGoose(t, "down-to", "4")
|
||||
if _, err = pool.Exec(ctx, `DROP TABLE goose_db_version;
|
||||
CREATE TABLE schema_migrations(version text PRIMARY KEY,applied_at timestamptz NOT NULL DEFAULT now());
|
||||
INSERT INTO schema_migrations(version) VALUES('001_initial.sql')`); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user