Skip to content

Commit a33a430

Browse files
committed
Add Test_httpGetForbidden
1 parent c4c42ae commit a33a430

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

internal_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,20 @@ func Test_httpGet(t *testing.T) {
2727
t.Error("\nGot :", got, "\nWant:", expected)
2828
}
2929
}
30+
31+
func Test_httpGetForbidden(t *testing.T) {
32+
txt := "please, do not try"
33+
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
34+
w.WriteHeader(http.StatusForbidden)
35+
_, err := fmt.Fprint(w, txt)
36+
if err != nil {
37+
println(err)
38+
}
39+
}))
40+
defer srv.Close()
41+
42+
_, _, err := httpGet(srv.URL)
43+
if err == nil {
44+
t.Error("Should not not be nil")
45+
}
46+
}

0 commit comments

Comments
 (0)