Skip to content

Commit f564bfd

Browse files
committed
fix: correct http status codes and endpoint validation in convo tests
- add missing http.statuscreated header in conversation models test - fix endpoint comparison logic for urls with query strings
1 parent 04e7e87 commit f564bfd

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

typesense/conversation_models_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ func TestConversationModelsCreate(t *testing.T) {
7979

8080
data := jsonEncode(t, expectedData)
8181
w.Header().Set("Content-Type", "application/json")
82+
w.WriteHeader(http.StatusCreated)
8283
w.Write(data)
8384
})
8485
defer server.Close()

typesense/utils_test.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"encoding/json"
55
"net/http"
66
"net/http/httptest"
7+
"strings"
78
"testing"
89

910
"github.com/stretchr/testify/assert"
@@ -15,8 +16,14 @@ func newTestServerAndClient(handler func(w http.ResponseWriter, r *http.Request)
1516
}
1617

1718
func validateRequestMetadata(t *testing.T, r *http.Request, expectedEndpoint string, expectedMethod string) {
18-
if r.RequestURI != expectedEndpoint {
19-
t.Fatal("Invalid request endpoint!")
19+
if strings.Contains(expectedEndpoint, "?") {
20+
if r.URL.String() != expectedEndpoint {
21+
t.Fatal("Invalid request endpoint!")
22+
}
23+
} else {
24+
if r.URL.Path != expectedEndpoint {
25+
t.Fatal("Invalid request endpoint!")
26+
}
2027
}
2128
if r.Method != expectedMethod {
2229
t.Fatal("Invalid HTTP method!")

0 commit comments

Comments
 (0)