agent: test config as a whole in services test

This commit is contained in:
Ryan Uber 2014-10-26 12:00:11 -07:00
parent 0eb5bef0d6
commit c1dfa55859

View File

@ -554,11 +554,9 @@ func TestDecodeConfig_Services(t *testing.T) {
t.Fatalf("err: %s", err) t.Fatalf("err: %s", err)
} }
if len(config.Services) != 2 { expected := &Config{
t.Fatalf("missing services") Services: []*ServiceDefinition{
} &ServiceDefinition{
expected := &ServiceDefinition{
Check: CheckType{ Check: CheckType{
Interval: 5 * time.Second, Interval: 5 * time.Second,
Script: "/bin/check_redis -p 6000", Script: "/bin/check_redis -p 6000",
@ -570,13 +568,8 @@ func TestDecodeConfig_Services(t *testing.T) {
"master", "master",
}, },
Port: 6000, Port: 6000,
} },
&ServiceDefinition{
if !reflect.DeepEqual(config.Services[0], expected) {
t.Fatalf("services do not match:\n%+v\n%+v", config.Services[0], expected)
}
expected = &ServiceDefinition{
Check: CheckType{ Check: CheckType{
Interval: 30 * time.Second, Interval: 30 * time.Second,
Script: "/bin/check_redis -p 7000", Script: "/bin/check_redis -p 7000",
@ -589,10 +582,12 @@ func TestDecodeConfig_Services(t *testing.T) {
"slave", "slave",
}, },
Port: 7000, Port: 7000,
},
},
} }
if !reflect.DeepEqual(config.Services[1], expected) { if !reflect.DeepEqual(config, expected) {
t.Fatalf("services do not match:\n%+v\n%+v", config.Services[1], expected) t.Fatalf("bad: %#v", config)
} }
} }