diff options
| author | Eugene Triguba <eugenetriguba@gmail.com> | 2024-03-09 12:07:30 -0500 |
|---|---|---|
| committer | Eugene Triguba <eugenetriguba@gmail.com> | 2024-03-09 12:07:30 -0500 |
| commit | 18cbade269362a3fed5763e2b1b39be33ba56aaf (patch) | |
| tree | d31df309169381b83f9cad67da15f38d0b3cccc6 /internal/bolttest | |
| parent | Add mysql docker compose file and use matrix in workflow (diff) | |
| download | cli-18cbade269362a3fed5763e2b1b39be33ba56aaf.zip | |
Fix tests to work without Dockerfile.test
Diffstat (limited to 'internal/bolttest')
| -rw-r--r-- | internal/bolttest/db.go | 10 | ||||
| -rw-r--r-- | internal/bolttest/env.go | 19 |
2 files changed, 24 insertions, 5 deletions
diff --git a/internal/bolttest/db.go b/internal/bolttest/db.go index bde519b..6ebbabf 100644 --- a/internal/bolttest/db.go +++ b/internal/bolttest/db.go @@ -12,16 +12,16 @@ import ( ) func NewTestConnectionConfig(t *testing.T, driver string) *configloader.ConnectionConfig { - port, err := strconv.Atoi(os.Getenv("DB_PORT")) + port, err := strconv.Atoi(os.Getenv("BOLT_DB_CONN_PORT")) assert.Nil(t, err) return &configloader.ConnectionConfig{ Driver: driver, - DBName: os.Getenv("DB_NAME"), - Host: os.Getenv("DB_HOST"), + DBName: os.Getenv("BOLT_DB_CONN_DBNAME"), + Host: os.Getenv("BOLT_DB_CONN_HOST"), Port: port, - User: os.Getenv("DB_USERNAME"), - Password: os.Getenv("DB_PASSWORD"), + User: os.Getenv("BOLT_DB_CONN_USER"), + Password: os.Getenv("BOLT_DB_CONN_PASSWORD"), } } diff --git a/internal/bolttest/env.go b/internal/bolttest/env.go new file mode 100644 index 0000000..8f0ad63 --- /dev/null +++ b/internal/bolttest/env.go @@ -0,0 +1,19 @@ +package bolttest + +import ( + "os" + "testing" + + "github.com/eugenetriguba/checkmate/assert" +) + +func UnsetEnv(t *testing.T, key string) { + originalVal, isSet := os.LookupEnv(key) + if isSet { + t.Cleanup(func() { + err := os.Setenv(key, originalVal) + assert.Nil(t, err) + }) + os.Unsetenv(key) + } +} |