Friends method in account service, String method for Post

Signed-off-by: Vartan Benohanian <vartanbeno@gmail.com>
This commit is contained in:
Vartan Benohanian
2020-06-29 21:38:47 -04:00
parent 33294aa036
commit f19965798c
4 changed files with 146 additions and 5 deletions
+31
View File
@@ -97,6 +97,21 @@ var expectedSettings = &Settings{
EnableVideoAutoplay: Bool(true),
}
var expectedFriends = []Friendship{
{
ID: "r9_1r4879",
Friend: "test1",
FriendID: "t2_test1",
Created: &Timestamp{time.Date(2020, 6, 28, 16, 43, 55, 0, time.UTC)},
},
{
ID: "r9_1re930",
Friend: "test2",
FriendID: "t2_test2",
Created: &Timestamp{time.Date(2020, 6, 28, 16, 44, 2, 0, time.UTC)},
},
}
func TestAccountService_Info(t *testing.T) {
setup()
defer teardown()
@@ -183,3 +198,19 @@ func TestAccountService_Trophies(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, expectedTrophies, trophies)
}
func TestAccountService_Friends(t *testing.T) {
setup()
defer teardown()
blob := readFileContents(t, "testdata/account/friends.json")
mux.HandleFunc("/prefs/friends", func(w http.ResponseWriter, r *http.Request) {
assert.Equal(t, http.MethodGet, r.Method)
fmt.Fprint(w, blob)
})
friends, _, err := client.Account.Friends(ctx)
assert.NoError(t, err)
assert.Equal(t, expectedFriends, friends)
}