func TestErrorStatusCode(t *testing.T) { hhtHelper := hhth.New(http.DefaultServeMux) hhtHelper.SetTestCase( hhth.TestCaseStatusCode(http.StatusFound), // error hhth.TestCaseContentType("text/plain; charset=utf-8"), hhth.TestCaseContentLength(len("hogehoge")), ) respError1 := hhtHelper.Get("/hoge") if respError1.Error() == nil { t.Error("error not error") } else { t.Logf("OK %s", respError1.Error()) } }
func TestHeadHogeHandler(t *testing.T) { hhtHelper := hhth.New(http.DefaultServeMux) hhtHelper.SetTestCase( hhth.TestCaseStatusCode(http.StatusOK), hhth.TestCaseContentType("text/plain; charset=utf-8"), hhth.TestCaseContentLength(len("hogehoge")), ) resp := hhtHelper.Head("/hoge") if resp.Error() != nil { t.Errorf("error %s", resp.Error()) } fmt.Println(resp.String()) }
func TestErrorContentType(t *testing.T) { hhtHelper := hhth.New(http.DefaultServeMux) hhtHelper.SetTestCase( hhth.TestCaseStatusCode(http.StatusOK), hhth.TestCaseContentType("application/json; charset=UTF-8"), // error hhth.TestCaseContentLength(len("hogehoge")), ) respError2 := hhtHelper.Get("/hoge") if respError2.Error() == nil { t.Error("error not error") } else { t.Logf("OK %s", respError2.Error()) } }