A pooled implementation of Twitch PubSub
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
1.2 KiB

package twpubsub
import "testing"
func TestVideoPlaybackByID(t *testing.T) {
msg, err := Decode([]byte(`{"topic":"video-playback-by-id.22484632","message":"{\"type\":\"viewcount\",\"server_time\":1604333700.632353,\"viewers\":19015}"}`))
if err != nil {
t.Error(err)
}
switch v := msg.(type) {
case VideoPlaybackByID:
default:
t.Errorf("Invalid type: %#v", v)
}
}
func TestResub(t *testing.T) {
msg, err := Decode([]byte("{\"topic\":\"dashboard-activity-feed.53381086\",\"message\":\"{\\\"id\\\":\\\"febce95f-147c-4226-a91e-cf0ee1df1df6\\\",\\\"timestamp\\\":\\\"2021-06-24T09:27:25.527884576Z\\\",\\\"type\\\":\\\"resubscription_sharing\\\",\\\"subscriber\\\":{\\\"id\\\":\\\"53381086\\\",\\\"login\\\":\\\"cbdg\\\",\\\"display_name\\\":\\\"cbdg\\\"},\\\"subscription_tier\\\":\\\"3000\\\",\\\"subscription_cumulative_tenure_months\\\":6,\\\"subscription_custom_message_text\\\":\\\"raccL cutest streamer on Twitch\\\",\\\"subscription_multi_month_duration\\\":0,\\\"subscription_multi_month_tenure\\\":0,\\\"alert_status\\\":\\\"offline\\\"}\"}"))
if err != nil {
t.Error(err)
}
switch v := msg.(type) {
case DashboardActivity:
default:
t.Errorf("Invalid type: %#v", v)
}
}