package starnet import ( "net/http" "net/http/httptest" "testing" ) func TestRequestConvenienceMethods(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Header().Set("X-Method", r.Method) w.WriteHeader(http.StatusOK) _, _ = w.Write([]byte("ok")) })) defer server.Close() tests := []struct { name string method string do func(r *Request) (*Response, error) }{ {name: "Head", method: http.MethodHead, do: (*Request).Head}, {name: "Patch", method: http.MethodPatch, do: (*Request).Patch}, {name: "Options", method: http.MethodOptions, do: (*Request).Options}, {name: "Trace", method: http.MethodTrace, do: (*Request).Trace}, {name: "Connect", method: http.MethodConnect, do: (*Request).Connect}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { req := NewSimpleRequest(server.URL, http.MethodGet) resp, err := tt.do(req) if err != nil { t.Fatalf("unexpected error: %v", err) } defer resp.Close() if got := resp.Header.Get("X-Method"); got != tt.method { t.Fatalf("method=%s want=%s", got, tt.method) } }) } }