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,45 +554,40 @@ 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{
Check: CheckType{
Interval: 5 * time.Second,
Script: "/bin/check_redis -p 6000",
TTL: 20 * time.Second,
},
ID: "red0",
Name: "redis",
Tags: []string{
"master",
},
Port: 6000,
},
&ServiceDefinition{
Check: CheckType{
Interval: 30 * time.Second,
Script: "/bin/check_redis -p 7000",
TTL: 60 * time.Second,
},
ID: "red1",
Name: "redis",
Tags: []string{
"delayed",
"slave",
},
Port: 7000,
},
},
} }
expected := &ServiceDefinition{ if !reflect.DeepEqual(config, expected) {
Check: CheckType{ t.Fatalf("bad: %#v", config)
Interval: 5 * time.Second,
Script: "/bin/check_redis -p 6000",
TTL: 20 * time.Second,
},
ID: "red0",
Name: "redis",
Tags: []string{
"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{
Check: CheckType{
Interval: 30 * time.Second,
Script: "/bin/check_redis -p 7000",
TTL: 60 * time.Second,
},
ID: "red1",
Name: "redis",
Tags: []string{
"delayed",
"slave",
},
Port: 7000,
}
if !reflect.DeepEqual(config.Services[1], expected) {
t.Fatalf("services do not match:\n%+v\n%+v", config.Services[1], expected)
} }
} }