Řekněme, že jsem testování funkce, která volá webové služby, a to služby je terčem posměchu s httptest.NewServer
func TestSomeFeature(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(200)
}))
SomeFeature(server.URL, "foo")
}
func SomeFeature(host, a string) {
if a == "foo" {
http.Get(fmt.Sprintf("%v/foo", host))
}
if a == "bar" {
http.Get(fmt.Sprintf("%v/bar", host))
}
}
Jak mohu tvrdit, že server byl nazýván se správnou url /foo
a nepodaří test, pokud to bylo voláno s nesprávnou adresu url nebo není volána vůbec?
server
?