✅ Improve test coverage
This commit is contained in:
parent
6f06adc37d
commit
d7de194a90
4 changed files with 75 additions and 0 deletions
|
|
@ -3,6 +3,7 @@ package config
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
|
@ -24,3 +25,40 @@ func TestValidEnvReturnsCorrect(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestConfigBaseURL(t *testing.T) {
|
||||
c := config{baseURL: "https://me.goodevilgenius.org"}
|
||||
assert.Equal(t, c.baseURL, c.BaseURL())
|
||||
}
|
||||
|
||||
func TestConfigStoreName(t *testing.T) {
|
||||
c := config{stores: stores{store: "cockroachdb"}}
|
||||
assert.Equal(t, c.stores.store, c.StoreName())
|
||||
}
|
||||
|
||||
func TestStoresMissingStore(t *testing.T) {
|
||||
ss := stores{}
|
||||
st, er := ss.GetStore("cockroachdb")
|
||||
assert.Nil(t, st)
|
||||
assert.ErrorIs(t, er, ErrMissingStore)
|
||||
}
|
||||
|
||||
var mockToml = `
|
||||
[cockroachdb]
|
||||
|
||||
dsn = "cockroachdb://user:pass@127.0.0.1:26257/combluotion"
|
||||
`
|
||||
|
||||
type mockConn struct {
|
||||
CockroachDB toml.Primitive
|
||||
}
|
||||
|
||||
func TestStoreMap(t *testing.T) {
|
||||
var conn mockConn
|
||||
md, _ := toml.Decode(mockToml, &conn)
|
||||
st := store{"cockroachdb", conn.CockroachDB, md}
|
||||
|
||||
m, er := st.Map()
|
||||
assert.NoError(t, er)
|
||||
assert.Equal(t, "cockroachdb://user:pass@127.0.0.1:26257/combluotion", m["dsn"])
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue