2019-10-22 19:55:43 +00:00
|
|
|
package config
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
2019-10-29 01:23:57 +00:00
|
|
|
const schemaPath string = "../config_schema.json"
|
2019-10-25 18:12:38 +00:00
|
|
|
|
2019-10-22 19:55:43 +00:00
|
|
|
func TestNoConfig(t *testing.T) {
|
2019-10-29 01:23:57 +00:00
|
|
|
_, err := ReadConfig("../test/sfklase.yml", schemaPath)
|
2019-10-22 19:55:43 +00:00
|
|
|
if err == nil {
|
|
|
|
t.Errorf("Non-existent config was successfully read")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestGoodConfig(t *testing.T) {
|
2019-10-29 01:23:57 +00:00
|
|
|
_, err := ReadConfig("../test/good_config.yml", schemaPath)
|
2019-10-22 19:55:43 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Errorf("Good config is not accepted: %v", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestBadConfig(t *testing.T) {
|
2019-10-29 01:23:57 +00:00
|
|
|
_, err := ReadConfig("../test/bad_config.yml", schemaPath)
|
2019-10-22 19:55:43 +00:00
|
|
|
if err == nil {
|
2019-10-25 18:12:38 +00:00
|
|
|
t.Errorf("Bad config is accepted but it shouldn't!")
|
|
|
|
} else {
|
|
|
|
t.Log(err)
|
2019-10-22 19:55:43 +00:00
|
|
|
}
|
|
|
|
}
|