diff options
| author | Eugene Triguba <eugenetriguba@gmail.com> | 2024-01-07 19:05:19 -0500 |
|---|---|---|
| committer | Eugene Triguba <eugenetriguba@gmail.com> | 2024-01-07 19:05:19 -0500 |
| commit | 4c296d8dacdd03c68a09a2d10266f193d97f5f0e (patch) | |
| tree | 2689dab2c8ebe857eb11169d8f85eab3faf1f7d2 /internal/storage | |
| parent | Move message normalization to create dirname to fs repo (diff) | |
| download | cli-4c296d8dacdd03c68a09a2d10266f193d97f5f0e.zip | |
Add shared test util package
Diffstat (limited to 'internal/storage')
| -rw-r--r-- | internal/storage/db_test.go | 6 | ||||
| -rw-r--r-- | internal/storage/dbtest/dbtest.go | 24 |
2 files changed, 3 insertions, 27 deletions
diff --git a/internal/storage/db_test.go b/internal/storage/db_test.go index 2583cfd..377c8c8 100644 --- a/internal/storage/db_test.go +++ b/internal/storage/db_test.go @@ -4,14 +4,14 @@ import ( "fmt" "testing" + "github.com/eugenetriguba/bolt/internal/bolttest" "github.com/eugenetriguba/bolt/internal/configloader" "github.com/eugenetriguba/bolt/internal/storage" - "github.com/eugenetriguba/bolt/internal/storage/dbtest" "gotest.tools/v3/assert" ) func TestDBConnectWithPostgres(t *testing.T) { - cfg, err := dbtest.NewTestConnectionConfig("postgres") + cfg, err := bolttest.NewTestConnectionConfig("postgres") assert.NilError(t, err) conn, err := storage.DBConnect(cfg.Driver, storage.DBConnectionString(cfg)) @@ -28,7 +28,7 @@ func TestDBConnectMalformedConnectionString(t *testing.T) { } func TestDBConnectUnsupportedDriver(t *testing.T) { - cfg, err := dbtest.NewTestConnectionConfig("redis") + cfg, err := bolttest.NewTestConnectionConfig("redis") assert.NilError(t, err) _, err = storage.DBConnect(cfg.Driver, storage.DBConnectionString(cfg)) diff --git a/internal/storage/dbtest/dbtest.go b/internal/storage/dbtest/dbtest.go deleted file mode 100644 index c53c04a..0000000 --- a/internal/storage/dbtest/dbtest.go +++ /dev/null @@ -1,24 +0,0 @@ -package dbtest - -import ( - "os" - "strconv" - - "github.com/eugenetriguba/bolt/internal/configloader" -) - -func NewTestConnectionConfig(driver string) (*configloader.ConnectionConfig, error) { - port, err := strconv.Atoi(os.Getenv("DB_PORT")) - if err != nil { - return nil, err - } - - return &configloader.ConnectionConfig{ - Driver: driver, - DBName: os.Getenv("DB_NAME"), - Host: os.Getenv("DB_HOST"), - Port: port, - User: os.Getenv("DB_USERNAME"), - Password: os.Getenv("DB_PASSWORD"), - }, nil -} |