Skip to content

Commit

Permalink
PMM-13132 Test DB.
Browse files Browse the repository at this point in the history
  • Loading branch information
JiriCtvrtka committed Sep 18, 2024
1 parent 7e58301 commit e8f94bf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion encryption-rotation/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestEncryptionRotation(t *testing.T) {
err = insertTestData(db)
require.NoError(t, err)

statusCode := rotate(db, testdb.TestDatabase)
statusCode := rotate(db, "pmm-managed-dev")
require.Equal(t, 0, statusCode)

newEncryptionKey, err := os.ReadFile(encryptionKeyTestPath)
Expand Down
9 changes: 4 additions & 5 deletions managed/utils/testdb/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ import (

const (
username, password = "postgres", ""
// TestDatabase contains name of pmm-managed DB used for tests.
TestDatabase = "pmm-managed-dev"
testDatabase = "pmm-managed-dev"
)

// Open recreates testing PostgreSQL database and returns an open connection to it.
Expand All @@ -47,15 +46,15 @@ func Open(tb testing.TB, setupFixtures models.SetupFixturesMode, migrationVersio
db, err := models.OpenDB(setupParams)
require.NoError(tb, err)

_, err = db.Exec(`DROP DATABASE IF EXISTS "` + TestDatabase + `"`)
_, err = db.Exec(`DROP DATABASE IF EXISTS "` + testDatabase + `"`)
require.NoError(tb, err)
_, err = db.Exec(`CREATE DATABASE "` + TestDatabase + `"`)
_, err = db.Exec(`CREATE DATABASE "` + testDatabase + `"`)
require.NoError(tb, err)

err = db.Close()
require.NoError(tb, err)

setupParams.Name = TestDatabase
setupParams.Name = testDatabase
db, err = models.OpenDB(setupParams)
require.NoError(tb, err)
SetupDB(tb, db, setupFixtures, migrationVersion)
Expand Down

0 comments on commit e8f94bf

Please sign in to comment.