2015-04-30 00:18:08 -04:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"reflect"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
var expectedConfigs []Config
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
expectedConfigs = []Config{
|
|
|
|
Config{
|
2015-05-02 21:56:41 -04:00
|
|
|
Username: "dev-account",
|
2015-04-30 00:18:08 -04:00
|
|
|
Token: "asdasdasdasdasdad",
|
|
|
|
Interval: 60,
|
2015-05-02 21:56:41 -04:00
|
|
|
Dev: true,
|
2015-04-30 00:18:08 -04:00
|
|
|
Domains: []string{"test.com", "fake.com"},
|
|
|
|
},
|
|
|
|
Config{
|
|
|
|
Username: "production-account",
|
|
|
|
Token: "123123123123",
|
|
|
|
Interval: 3600,
|
|
|
|
Domains: []string{"live.com", "abc.live.com"},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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")
|
|
|
|
}
|
|
|
|
}
|