MCPcopy Create free account
hub / github.com/danielmiessler/Fabric / TestSearchReturnsAPIError

Function TestSearchReturnsAPIError

internal/tools/sofya/sofya_test.go:69–81  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

67}
68
69func TestSearchReturnsAPIError(t *testing.T) {
70 newTestServer(t, func(w http.ResponseWriter, r *http.Request) {
71 w.WriteHeader(http.StatusUnauthorized)
72 _, _ = w.Write([]byte(`{"detail":"Invalid API key"}`))
73 })
74
75 client := NewClient()
76 client.ApiKey.Value = "bad"
77
78 _, err := client.Search("anything")
79 require.ErrorContains(t, err, "401")
80 require.ErrorContains(t, err, "Invalid API key")
81}
82
83func TestSearchReturnsEmptyWhenNoResults(t *testing.T) {
84 newTestServer(t, func(w http.ResponseWriter, r *http.Request) {

Callers

nothing calls this directly

Calls 4

SearchMethod · 0.95
WriteMethod · 0.80
newTestServerFunction · 0.70
NewClientFunction · 0.70

Tested by

no test coverage detected