From 83809d81d577f5e5a85523474ac82bede1baa23e Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Sun, 10 May 2020 06:52:48 +0200 Subject: [PATCH] Better postgresql test defaults on OSX (#3244) Co-authored-by: Liang Mei Co-authored-by: Yichao Yang --- .../postgres/postgres_server_test.go | 20 +++++++++++++++++-- environment/env.go | 10 +++++----- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/common/persistence/sql/sqlplugin/postgres/postgres_server_test.go b/common/persistence/sql/sqlplugin/postgres/postgres_server_test.go index eec78ffe2da..78cc668e27d 100644 --- a/common/persistence/sql/sqlplugin/postgres/postgres_server_test.go +++ b/common/persistence/sql/sqlplugin/postgres/postgres_server_test.go @@ -21,6 +21,8 @@ package postgres import ( + "os" + "runtime" "testing" "github.com/stretchr/testify/suite" @@ -30,12 +32,26 @@ import ( ) const ( - testUser = "postgres" - testPassword = "cadence" testSchemaDir = "schema/postgres" ) func getTestClusterOption() *pt.TestBaseOptions { + testUser := "postgres" + testPassword := "cadence" + + if runtime.GOOS == "darwin" { + testUser = os.Getenv("USER") + testPassword = "" + } + + if os.Getenv("POSTGRES_USER") != "" { + testUser = os.Getenv("POSTGRES_USER") + } + + if os.Getenv("POSTGRES_PASSWORD") != "" { + testUser = os.Getenv("POSTGRES_PASSWORD") + } + return &pt.TestBaseOptions{ SQLDBPluginName: PluginName, DBUsername: testUser, diff --git a/environment/env.go b/environment/env.go index b3728c3563a..b9c1db36d64 100644 --- a/environment/env.go +++ b/environment/env.go @@ -161,7 +161,7 @@ func GetCassandraPort() int { return p } -// GetMySQLAddress return the cassandra address +// GetMySQLAddress return the MySQL address func GetMySQLAddress() string { addr := os.Getenv(MySQLSeeds) if addr == "" { @@ -183,7 +183,7 @@ func GetMySQLPort() int { return p } -// GetPostgresAddress return the cassandra address +// GetPostgresAddress return the Postgres address func GetPostgresAddress() string { addr := os.Getenv(PostgresSeeds) if addr == "" { @@ -205,7 +205,7 @@ func GetPostgresPort() int { return p } -// GetKafkaAddress return the kafka address +// GetKafkaAddress return the Kafka address func GetKafkaAddress() string { addr := os.Getenv(KafkaSeeds) if addr == "" { @@ -227,7 +227,7 @@ func GetKafkaPort() int { return p } -// GetESAddress return the kafka address +// GetESAddress return the ElasticSearch address func GetESAddress() string { addr := os.Getenv(ESSeeds) if addr == "" { @@ -236,7 +236,7 @@ func GetESAddress() string { return addr } -// GetESPort return the Kafka port +// GetESPort return the ElasticSearch port func GetESPort() int { port := os.Getenv(ESPort) if port == "" {