wings/config/config_test.go

30 lines
610 B
Go
Raw Normal View History

2017-06-26 19:04:11 +00:00
package config
import (
"testing"
"github.com/spf13/viper"
2017-06-26 19:04:11 +00:00
"github.com/stretchr/testify/assert"
)
const configFile = "../config.yml.example"
2017-06-26 19:04:11 +00:00
func TestLoadConfiguraiton(t *testing.T) {
2017-07-06 18:49:36 +00:00
err := LoadConfiguration(configFile)
2017-06-26 19:04:11 +00:00
assert.Nil(t, err)
assert.Equal(t, "0.0.0.0", viper.GetString(APIHost))
2017-06-26 19:04:11 +00:00
}
2017-07-06 18:49:36 +00:00
func TestContainsAuthKey(t *testing.T) {
t.Run("key exists", func(t *testing.T) {
LoadConfiguration(configFile)
assert.True(t, ContainsAuthKey("somekey"))
2017-07-06 18:49:36 +00:00
})
t.Run("key doesn't exist", func(t *testing.T) {
LoadConfiguration(configFile)
assert.False(t, ContainsAuthKey("someotherkey"))
2017-07-06 18:49:36 +00:00
})
}