Add UpvotedOf and DownvotedOf methods

Signed-off-by: Vartan Benohanian <vartanbeno@gmail.com>
This commit is contained in:
Vartan Benohanian
2020-07-03 14:27:56 -04:00
parent 6ffcf70090
commit c199a4f712
2 changed files with 59 additions and 4 deletions
+43
View File
@@ -490,6 +490,28 @@ func TestUserService_Upvoted_Options(t *testing.T) {
_, _, err := client.User.Upvoted(ctx, SetLimit(30), SetAfter("t3_after"))
assert.NoError(t, err)
}
func TestUserService_UpvotedOf(t *testing.T) {
setup()
defer teardown()
// we'll use this, similar payloads
blob := readFileContents(t, "testdata/user/submitted.json")
mux.HandleFunc("/user/user2/upvoted", func(w http.ResponseWriter, r *http.Request) {
assert.Equal(t, http.MethodGet, r.Method)
fmt.Fprint(w, blob)
})
posts, _, err := client.User.UpvotedOf(ctx, "user2")
assert.NoError(t, err)
assert.Len(t, posts.Posts, 1)
assert.Equal(t, expectedPost, posts.Posts[0])
assert.Equal(t, "t3_gczwql", posts.After)
assert.Equal(t, "", posts.Before)
}
func TestUserService_Downvoted(t *testing.T) {
setup()
defer teardown()
@@ -536,6 +558,27 @@ func TestUserService_Downvoted_Options(t *testing.T) {
assert.NoError(t, err)
}
func TestUserService_DownvotedOf(t *testing.T) {
setup()
defer teardown()
// we'll use this, similar payloads
blob := readFileContents(t, "testdata/user/submitted.json")
mux.HandleFunc("/user/user2/downvoted", func(w http.ResponseWriter, r *http.Request) {
assert.Equal(t, http.MethodGet, r.Method)
fmt.Fprint(w, blob)
})
posts, _, err := client.User.DownvotedOf(ctx, "user2")
assert.NoError(t, err)
assert.Len(t, posts.Posts, 1)
assert.Equal(t, expectedPost, posts.Posts[0])
assert.Equal(t, "t3_gczwql", posts.After)
assert.Equal(t, "", posts.Before)
}
func TestUserService_Hidden(t *testing.T) {
setup()
defer teardown()