-
Notifications
You must be signed in to change notification settings - Fork 1
/
apichecker_test.go
executable file
·61 lines (45 loc) · 1.42 KB
/
apichecker_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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package main
import (
"github.com/stretchr/testify/assert"
"net/url"
"testing"
)
func TestAPICheckRecentPlayURLConstructor(t *testing.T) {
apichecker := NewAPIChecker("username", "apikey")
constructedurl, err := apichecker.constructRecentPlayURL()
assert.Nil(t, err)
apiurl, err := url.Parse("http://osu.ppy.sh/api/get_user_recent")
assert.Nil(t, err)
query := apiurl.Query()
query.Set("k", "apikey")
query.Set("u", "username")
query.Set("limit", "1")
query.Set("type", "string")
apiurl.RawQuery = query.Encode()
assert.Equal(t, apiurl, constructedurl)
}
func TestAPICheckUserGetURLConstructor(t *testing.T) {
apichecker := NewAPIChecker("username", "apikey")
constructedurl, err := apichecker.constructUserGetURL()
assert.Nil(t, err)
apiurl, err := url.Parse("http://osu.ppy.sh/api/get_user")
assert.Nil(t, err)
query := apiurl.Query()
query.Set("k", "apikey")
query.Set("u", "username")
query.Set("type", "string")
apiurl.RawQuery = query.Encode()
assert.Equal(t, apiurl, constructedurl)
}
func TestAPICheckBeatmapGetURLConstructor(t *testing.T) {
apichecker := NewAPIChecker("username", "apikey")
constructedurl, err := apichecker.constructBeatmapGetURL(1)
assert.Nil(t, err)
apiurl, err := url.Parse("http://osu.ppy.sh/api/get_beatmaps")
assert.Nil(t, err)
query := apiurl.Query()
query.Set("k", "apikey")
query.Set("b", "1")
apiurl.RawQuery = query.Encode()
assert.Equal(t, apiurl, constructedurl)
}