Fix streaming_ws local
parent
f4cf4d4ec9
commit
c1e9c80d7d
|
@ -24,29 +24,29 @@ type Stream struct {
|
|||
Payload interface{} `json:"payload"`
|
||||
}
|
||||
|
||||
// StreamingWSPublic return channel to read events on public using WebSocket.
|
||||
func (c *WSClient) StreamingWSPublic(ctx context.Context) (chan Event, error) {
|
||||
return c.streamingWS(ctx, "public", "")
|
||||
}
|
||||
|
||||
// StreamingWSPublicLocal return channel to read events on public local using WebSocket.
|
||||
func (c *WSClient) StreamingWSPublicLocal(ctx context.Context) (chan Event, error) {
|
||||
return c.streamingWS(ctx, "public:local", "")
|
||||
}
|
||||
|
||||
// StreamingWSUser return channel to read events on home using WebSocket.
|
||||
func (c *WSClient) StreamingWSUser(ctx context.Context) (chan Event, error) {
|
||||
return c.streamingWS(ctx, "user", "")
|
||||
}
|
||||
|
||||
// StreamingWSHashtag return channel to read events on tagged timeline using WebSocket.
|
||||
func (c *WSClient) StreamingWSHashtag(ctx context.Context, tag string) (chan Event, error) {
|
||||
return c.streamingWS(ctx, "hashtag", tag)
|
||||
// StreamingWSPublic return channel to read events on public using WebSocket.
|
||||
func (c *WSClient) StreamingWSPublic(ctx context.Context, isLocal bool) (chan Event, error) {
|
||||
s := "public"
|
||||
if isLocal {
|
||||
s += ":local"
|
||||
}
|
||||
|
||||
return c.streamingWS(ctx, s, "")
|
||||
}
|
||||
|
||||
// StreamingWSHashtagLocal return channel to read events on tagged local timeline using WebSocket.
|
||||
func (c *WSClient) StreamingWSHashtagLocal(ctx context.Context, tag string) (chan Event, error) {
|
||||
return c.streamingWS(ctx, "hashtag:local", tag)
|
||||
// StreamingWSHashtag return channel to read events on tagged timeline using WebSocket.
|
||||
func (c *WSClient) StreamingWSHashtag(ctx context.Context, tag string, isLocal bool) (chan Event, error) {
|
||||
s := "hashtag"
|
||||
if isLocal {
|
||||
s += ":local"
|
||||
}
|
||||
|
||||
return c.streamingWS(ctx, s, tag)
|
||||
}
|
||||
|
||||
func (c *WSClient) streamingWS(ctx context.Context, stream, tag string) (chan Event, error) {
|
||||
|
|
|
@ -16,21 +16,7 @@ func TestStreamingWSPublic(t *testing.T) {
|
|||
|
||||
client := NewClient(&Config{Server: ts.URL}).NewWSClient()
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
q, err := client.StreamingWSPublic(ctx)
|
||||
if err != nil {
|
||||
t.Fatalf("should not be fail: %v", err)
|
||||
}
|
||||
|
||||
wsTest(t, q, cancel)
|
||||
}
|
||||
|
||||
func TestStreamingWSPublicLocal(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.StreamingWSPublicLocal(ctx)
|
||||
q, err := client.StreamingWSPublic(ctx, false)
|
||||
if err != nil {
|
||||
t.Fatalf("should not be fail: %v", err)
|
||||
}
|
||||
|
@ -58,21 +44,7 @@ func TestStreamingWSHashtag(t *testing.T) {
|
|||
|
||||
client := NewClient(&Config{Server: ts.URL}).NewWSClient()
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
q, err := client.StreamingWSHashtag(ctx, "zzz")
|
||||
if err != nil {
|
||||
t.Fatalf("should not be fail: %v", err)
|
||||
}
|
||||
|
||||
wsTest(t, q, cancel)
|
||||
}
|
||||
|
||||
func TestStreamingWSHashtagLocal(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.StreamingWSHashtagLocal(ctx, "zzz")
|
||||
q, err := client.StreamingWSHashtag(ctx, "zzz", false)
|
||||
if err != nil {
|
||||
t.Fatalf("should not be fail: %v", err)
|
||||
}
|
||||
|
@ -156,7 +128,7 @@ func TestStreamingWS(t *testing.T) {
|
|||
defer ts.Close()
|
||||
|
||||
client := NewClient(&Config{Server: ":"}).NewWSClient()
|
||||
_, err := client.StreamingWSPublicLocal(context.Background())
|
||||
_, err := client.StreamingWSPublic(context.Background(), true)
|
||||
if err == nil {
|
||||
t.Fatalf("should be fail: %v", err)
|
||||
}
|
||||
|
@ -164,7 +136,7 @@ func TestStreamingWS(t *testing.T) {
|
|||
client = NewClient(&Config{Server: ts.URL}).NewWSClient()
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
cancel()
|
||||
q, err := client.StreamingWSPublicLocal(ctx)
|
||||
q, err := client.StreamingWSPublic(ctx, true)
|
||||
if err != nil {
|
||||
t.Fatalf("should not be fail: %v", err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue