lab5 done

This commit is contained in:
Khakimov Dmitrij
2026-11-10 22:13:40 +03:00
parent b2bd7501d3
commit cbe9d8748c
63 changed files with 8907 additions and 307 deletions
@@ -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 {