MCPcopy Create free account
hub / github.com/BryanMwangi/pine / TestClient_SendRequest

Function TestClient_SendRequest

client_test.go:93–112  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

91}
92
93func TestClient_SendRequest(t *testing.T) {
94 // Setup a test server
95 ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
96 w.WriteHeader(http.StatusOK)
97 w.Write([]byte("success"))
98 }))
99 defer ts.Close()
100
101 client := NewClient()
102 req := client.Request()
103 req.SetRequestURI(ts.URL).SetMethod("GET")
104
105 err := client.SendRequest()
106 if err != nil {
107 t.Fatalf("expected no error, got %v", err)
108 }
109 if client.res.StatusCode != http.StatusOK {
110 t.Fatalf("expected status code 200, got %d", client.res.StatusCode)
111 }
112}
113
114func TestClient_SendRequest_MissingURI(t *testing.T) {
115 client := NewClient()

Callers

nothing calls this directly

Calls 7

RequestMethod · 0.95
SendRequestMethod · 0.95
NewClientFunction · 0.85
WriteHeaderMethod · 0.80
SetMethodMethod · 0.80
SetRequestURIMethod · 0.80
WriteMethod · 0.45

Tested by

no test coverage detected