2017-06-26 19:04:11 +00:00
|
|
|
package config
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2017-08-31 22:05:36 +00:00
|
|
|
"github.com/spf13/viper"
|
|
|
|
|
2017-06-26 19:04:11 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
2017-09-30 22:25:04 +00:00
|
|
|
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)
|
2017-08-31 22:05:36 +00:00
|
|
|
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)
|
2017-08-31 22:05:36 +00:00
|
|
|
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)
|
2017-08-31 22:05:36 +00:00
|
|
|
assert.False(t, ContainsAuthKey("someotherkey"))
|
2017-07-06 18:49:36 +00:00
|
|
|
})
|
|
|
|
}
|