-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a6bff33
commit 73ac6b8
Showing
2 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"data": [ | ||
{ | ||
"id": "141981764", | ||
"login": "twitchdev", | ||
"display_name": "TwitchDev", | ||
"type": "", | ||
"broadcaster_type": "partner", | ||
"description": "Supporting third-party developers building Twitch integrations from chatbots to game integrations.", | ||
"profile_image_url": "https://static-cdn.jtvnw.net/jtv_user_pictures/8a6381c7-d0c0-4576-b179-38bd5ce1d6af-profile_image-300x300.png", | ||
"offline_image_url": "https://static-cdn.jtvnw.net/jtv_user_pictures/3f13ab61-ec78-4fe6-8481-8682cb3b0ac2-channel_offline_image-1920x1080.png", | ||
"view_count": 5980557, | ||
"email": "[email protected]", | ||
"created_at": "2016-12-14T20:32:28Z" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package twitch | ||
|
||
import ( | ||
"context" | ||
"net/http" | ||
"testing" | ||
|
||
"github.com/google/go-cmp/cmp" | ||
"golang.org/x/oauth2" | ||
) | ||
|
||
func TestUsers(t *testing.T) { | ||
t.Run("decode", func(t *testing.T) { | ||
spy := apiresp(200, "users.json") | ||
cl := Client{ | ||
HTTP: &http.Client{ | ||
Transport: spy, | ||
}, | ||
Token: &oauth2.Token{ | ||
AccessToken: "bocchi", | ||
}, | ||
} | ||
u := []User{ | ||
{ID: "141981764"}, | ||
{Login: "twitchdev"}, | ||
} | ||
u, err := Users(context.Background(), cl, u) | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
if len(u) != 1 { | ||
t.Fatalf("wrong number of results: want 1, got %d", len(u)) | ||
} | ||
want := User{ | ||
ID: "141981764", | ||
Login: "twitchdev", | ||
DisplayName: "TwitchDev", | ||
Type: "", | ||
BroadcasterType: "partner", | ||
Description: "Supporting third-party developers building Twitch integrations from chatbots to game integrations.", | ||
ProfileImageURL: "https://static-cdn.jtvnw.net/jtv_user_pictures/8a6381c7-d0c0-4576-b179-38bd5ce1d6af-profile_image-300x300.png", | ||
OfflineImageURL: "https://static-cdn.jtvnw.net/jtv_user_pictures/3f13ab61-ec78-4fe6-8481-8682cb3b0ac2-channel_offline_image-1920x1080.png", | ||
ViewCount: 5980557, | ||
Email: "[email protected]", | ||
CreatedAt: "2016-12-14T20:32:28Z", | ||
} | ||
got := u[0] | ||
if diff := cmp.Diff(got, want); diff != "" { | ||
t.Errorf("wrong result (+got/-want):\n%s", diff) | ||
} | ||
}) | ||
} |