agent: test config as a whole in services test

pull/436/head
Ryan Uber 2014-10-26 12:00:11 -07:00
parent 0eb5bef0d6
commit c1dfa55859
1 changed files with 32 additions and 37 deletions

View File

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