telegabber/config/config_test.go

31 lines
630 B
Go
Raw Normal View History

package config
import (
"testing"
)
2019-10-25 18:12:38 +00:00
const SCHEMA_PATH string = "../config_schema.json"
func TestNoConfig(t *testing.T) {
2019-10-25 18:12:38 +00:00
_, err := ReadConfig("../test/sfklase.yml", SCHEMA_PATH)
if err == nil {
t.Errorf("Non-existent config was successfully read")
}
}
func TestGoodConfig(t *testing.T) {
2019-10-25 18:12:38 +00:00
_, err := ReadConfig("../test/good_config.yml", SCHEMA_PATH)
if err != nil {
t.Errorf("Good config is not accepted: %v", err)
}
}
func TestBadConfig(t *testing.T) {
2019-10-25 18:12:38 +00:00
_, err := ReadConfig("../test/bad_config.yml", SCHEMA_PATH)
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)
}
}