Skip to content

Commit

Permalink
Better postgresql test defaults on OSX (#3244)
Browse files Browse the repository at this point in the history
Co-authored-by: Liang Mei <[email protected]>
Co-authored-by: Yichao Yang <[email protected]>
  • Loading branch information
3 people authored May 10, 2020
1 parent df82425 commit 83809d8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
20 changes: 18 additions & 2 deletions common/persistence/sql/sqlplugin/postgres/postgres_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
package postgres

import (
"os"
"runtime"
"testing"

"github.com/stretchr/testify/suite"
Expand All @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions environment/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "" {
Expand All @@ -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 == "" {
Expand All @@ -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 == "" {
Expand All @@ -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 == "" {
Expand All @@ -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 == "" {
Expand Down

0 comments on commit 83809d8

Please sign in to comment.