Unverified Commit 72934a86 authored by bryanl's avatar bryanl
Browse files

adding tests for option loader types


Signed-off-by: default avatarbryanl <bryanliles@gmail.com>
parent 5127e0ca
...@@ -53,19 +53,61 @@ func Test_optionsLoader_loadApp(t *testing.T) { ...@@ -53,19 +53,61 @@ func Test_optionsLoader_loadApp(t *testing.T) {
for _, tc := range cases { for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
ol := newOptionLoader(tc.m) withOptionLoader(t, tc.m, func(a *mocks.App, ol *optionLoader) {
got := ol.loadApp()
got := ol.loadApp() if tc.isErr {
if tc.isErr { require.Error(t, ol.err)
require.Error(t, ol.err) return
return }
}
require.NoError(t, ol.err)
require.NoError(t, ol.err) assert.Equal(t, a, got)
assert.Equal(t, a, got) })
}) })
} }
})
}
// func Test_optionsLoader_loadBool(t *testing.T) {
// withApp(t, func(a *mocks.App) {
// cases := []struct {
// name string
// key string
// validCase interface{}
// invalidCase interface{}
// }{
// {
// name: "bool",
// key: OptionGcTag,
// validCase: true,
// invalidCase: "invalid"
// },
// }
// for _, tc := range cases {
// t.Run(tc.name, func(t *testing.T) {
// m := map[string]interface{
// tc.key: tc.validCase,
// }
// ol := newOptionLoader(m)
// got := ol.loadApp()
// if tc.isErr {
// require.Error(t, ol.err)
// return
// }
// require.NoError(t, ol.err)
// assert.Equal(t, a, got)
// })
// }
// })
// }
func withOptionLoader(t *testing.T, m map[string]interface{}, fn func(*mocks.App, *optionLoader)) {
withApp(t, func(a *mocks.App) {
ol := newOptionLoader(m)
fn(a, ol)
}) })
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment