Use IntOrString for HTTP health check ports

Clean up code to be more testable.  Add test cases for named and numeric
ports in HTTP health checks.  Improve tests.
This commit is contained in:
Tim Hockin
2014-08-10 23:26:42 -07:00
parent e35dfedd79
commit 7201227cb1
8 changed files with 153 additions and 48 deletions

View File

@@ -71,6 +71,20 @@ func TestHandleCrash(t *testing.T) {
}
}
func TestMakeIntOrStringFromInt(t *testing.T) {
i := MakeIntOrStringFromInt(93)
if i.Kind != IntstrInt || i.IntVal != 93 {
t.Errorf("Expected IntVal=93, got %+v", i)
}
}
func TestMakeIntOrStringFromString(t *testing.T) {
i := MakeIntOrStringFromString("76")
if i.Kind != IntstrString || i.StrVal != "76" {
t.Errorf("Expected StrVal=\"76\", got %+v", i)
}
}
type IntOrStringHolder struct {
IOrS IntOrString `json:"val" yaml:"val"`
}