-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathutils_test.go
35 lines (29 loc) · 1.05 KB
/
utils_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package pixiv
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestParseBookmarkNextPageURL(t *testing.T) {
r := require.New(t)
next, err := parseNextPageOffset("https://app-api.pixiv.net/v1/user/bookmarks/illust?filter=for_ios&restrict=private&user_id=60984430&max_bookmark_id=21354656694", OffsetFieldMaxBookmarkID)
r.Nil(err)
r.Equal(21354656694, next)
}
func TestParseOffsetNextPageURL(t *testing.T) {
r := require.New(t)
next, err := parseNextPageOffset("https://app-api.pixiv.net/v1/user/illusts?filter=for_ios&type=illust&user_id=490219&offset=30", OffsetFieldOffset)
r.Nil(err)
r.Equal(30, next)
}
func TestParseEmptyNextPageURL(t *testing.T) {
r := require.New(t)
next, err := parseNextPageOffset("", OffsetFieldOffset)
r.Nil(err)
r.Equal(0, next)
}
func TestParseInvalidNextPageURL(t *testing.T) {
r := require.New(t)
next, err := parseNextPageOffset("https://app-api.pixiv.net/v1/user/illusts?filter=for_ios&type=illust&user_id=490219&offset=30", "invalid")
r.EqualError(err, "offset param omitted: invalid")
r.Equal(0, next)
}