Skip to content

Commit

Permalink
fix: address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
GAlexIHU committed Jul 31, 2024
1 parent 29ce060 commit 19cb2f2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 22 deletions.
1 change: 0 additions & 1 deletion e2e/diff/.gitignore

This file was deleted.

27 changes: 10 additions & 17 deletions e2e/diff/no_schema_diff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,42 +14,35 @@ import (
"github.com/openmeterio/openmeter/pkg/framework/entutils"
)

var PG_URL string
var pgUrl string

func TestMain(m *testing.M) {
PG_URL = os.Getenv("POSTGRES_URL")
pgUrl = os.Getenv("POSTGRES_URL")

os.Exit(m.Run())
}

const (
DIR = "./tmp/"
)

func setup(t *testing.T) {
if PG_URL == "" {
t.Helper()
if pgUrl == "" {
t.Skip("POSTGRES_URL not set")
}
}

func TestNoSchemaDiffOnMigrate(t *testing.T) {
setup(t)
driver, err := entutils.GetPGDriver(PG_URL)
driver, err := entutils.GetPGDriver(pgUrl)
if err != nil {
t.Fatalf("failed to get pg driver %s", err)
}

// OpenMemDir doesn't work from inside dagger
// dir := migrate.OpenMemDir("migrations")
err = os.RemoveAll(DIR)
tmpDirPath, err := os.MkdirTemp("", "migrate")
if err != nil {
t.Fatalf("failed to remove dir %s", err)
t.Fatalf("failed to create temp dir %s", err)
}
err = os.MkdirAll(DIR, os.ModePerm)
if err != nil {
t.Fatalf("failed to create dir %s", err)
}
dir, err := migrate.NewLocalDir(DIR)
defer os.RemoveAll(tmpDirPath)

dir, err := migrate.NewLocalDir(tmpDirPath)
if err != nil {
t.Fatalf("failed to open local dir %s", err)
}
Expand Down
8 changes: 4 additions & 4 deletions tools/migrate/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import (
)

func main() {
PG_URL := os.Getenv("POSTGRES_URL")
if PG_URL == "" {
PG_URL = "postgres://postgres:postgres@localhost:5432/postgres"
pgUrl := os.Getenv("POSTGRES_URL")
if pgUrl == "" {
pgUrl = "postgres://postgres:postgres@localhost:5432/postgres"
}

logger := slog.New(slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{Level: slog.LevelDebug}))
slog.SetDefault(logger)

driver, err := entutils.GetPGDriver(PG_URL)
driver, err := entutils.GetPGDriver(pgUrl)
if err != nil {
logger.Error("failed to get pg driver", slog.Any("error", err))
os.Exit(1)
Expand Down

0 comments on commit 19cb2f2

Please sign in to comment.