-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathapi_test.go
40 lines (35 loc) · 820 Bytes
/
api_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
package mangodex
import (
"fmt"
"net/url"
"os"
"strconv"
"testing"
)
var client = NewDexClient()
func TestLogin(t *testing.T) {
err := client.Auth.Login(os.Getenv("USERNAME"), os.Getenv("PASSWORD"))
if err != nil {
t.Error("Login failed.")
}
fmt.Printf("%v\n", client)
}
func TestGetLoggedUser(t *testing.T) {
user, err := client.User.GetLoggedUser()
if err != nil {
t.Error("Getting user failed.")
}
t.Log(user)
}
func TestGetMangaList(t *testing.T) {
params := url.Values{}
params.Set("limit", strconv.Itoa(100))
params.Set("offset", strconv.Itoa(0))
// Include Author relationship
params.Set("includes[]", AuthorRel)
// If it is a search, then we add the search term.
_, err := client.Manga.GetMangaList(params)
if err != nil {
t.Errorf("Getting manga failed: %s\n", err.Error())
}
}