aboutsummaryrefslogtreecommitdiffstats
path: root/internal/storage/db_test.go
diff options
context:
space:
mode:
authorEugene Triguba <eugenetriguba@gmail.com>2024-02-25 16:03:14 -0500
committerEugene Triguba <eugenetriguba@gmail.com>2024-02-25 16:03:14 -0500
commited987d2d21e4063fcdb83e86d9f87b08f8e2165a (patch)
tree03eb2196ce2fa2e0af11c7ea6dabbcafe749430d /internal/storage/db_test.go
parentAdd error handling to unhandled errors during migration apply/revert (diff)
downloadcli-ed987d2d21e4063fcdb83e86d9f87b08f8e2165a.zip
Add better error handling for db connect
Diffstat (limited to 'internal/storage/db_test.go')
-rw-r--r--internal/storage/db_test.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/internal/storage/db_test.go b/internal/storage/db_test.go
index 61a9bf4..c871c47 100644
--- a/internal/storage/db_test.go
+++ b/internal/storage/db_test.go
@@ -10,7 +10,7 @@ import (
"github.com/eugenetriguba/checkmate/assert"
)
-func TestDBConnectWithPostgres(t *testing.T) {
+func TestDBConnect_Success(t *testing.T) {
cfg := bolttest.NewTestConnectionConfig(t, "postgres")
conn, err := storage.DBConnect(cfg.Driver, storage.DBConnectionString(cfg))
@@ -21,15 +21,17 @@ func TestDBConnectWithPostgres(t *testing.T) {
assert.Nil(t, err)
}
-func TestDBConnectMalformedConnectionString(t *testing.T) {
+func TestDBConnect_BadConnectionString(t *testing.T) {
_, err := storage.DBConnect("postgres", "pizza=123")
+ assert.ErrorIs(t, err, storage.ErrUnableToConnect)
assert.ErrorContains(t, err, "connection refused")
}
-func TestDBConnectUnsupportedDriver(t *testing.T) {
+func TestDBConnect_UnsupportedDriver(t *testing.T) {
cfg := bolttest.NewTestConnectionConfig(t, "redis")
_, err := storage.DBConnect(cfg.Driver, storage.DBConnectionString(cfg))
+ assert.ErrorIs(t, err, storage.ErrInvalidConnectionString)
assert.ErrorContains(t, err, `unknown driver "redis"`)
}