fix more tests

This commit is contained in:
Rasmus Lindroth 2022-12-30 12:38:22 +01:00
parent 2a17549744
commit 2b33d0ed4b
2 changed files with 42 additions and 3 deletions

View file

@ -59,6 +59,32 @@ func TestStreamingWSHashtag(t *testing.T) {
wsTest(t, q, cancel)
}
func TestStreamingWSList(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(wsMock))
defer ts.Close()
client := NewClient(&Config{Server: ts.URL}).NewWSClient()
ctx, cancel := context.WithCancel(context.Background())
q, err := client.StreamingWSList(ctx, "123")
if err != nil {
t.Fatalf("should not be fail: %v", err)
}
wsTest(t, q, cancel)
}
func TestStreamingWSDirect(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(wsMock))
defer ts.Close()
client := NewClient(&Config{Server: ts.URL}).NewWSClient()
ctx, cancel := context.WithCancel(context.Background())
q, err := client.StreamingWSDirect(ctx)
if err != nil {
t.Fatalf("should not be fail: %v", err)
}
wsTest(t, q, cancel)
}
func wsMock(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != "/api/v1/streaming" {
http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound)