2015-04-30 00:18:08 -04:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"reflect"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
var expectedConfigs []Config
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
expectedConfigs = []Config{
|
2015-05-07 21:28:41 -04:00
|
|
|
{
|
2015-05-04 03:07:14 -04:00
|
|
|
Username: "dev-account",
|
|
|
|
Token: "asdasdasdasdasdad",
|
|
|
|
Interval: 60,
|
|
|
|
Dev: true,
|
|
|
|
Domain: "test.com",
|
|
|
|
Hostnames: []string{"mail", "chat"},
|
2015-04-30 00:18:08 -04:00
|
|
|
},
|
2015-05-07 21:28:41 -04:00
|
|
|
{
|
2015-05-04 03:07:14 -04:00
|
|
|
Username: "production-account",
|
|
|
|
Token: "123123123123",
|
|
|
|
Interval: 3600,
|
|
|
|
Domain: "live.com",
|
|
|
|
Hostnames: []string{"mail", "support"},
|
2015-04-30 00:18:08 -04:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestLoadConfigs(t *testing.T) {
|
|
|
|
configs, err := LoadConfigs("./config_test.json")
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("Failed to load configs: %s\n", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if !reflect.DeepEqual(expectedConfigs, configs) {
|
|
|
|
t.Fatalf("Unexpected configuration")
|
|
|
|
}
|
|
|
|
}
|