fix more tests
This commit is contained in:
parent
2a17549744
commit
2b33d0ed4b
2 changed files with 42 additions and 3 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue