-
Notifications
You must be signed in to change notification settings - Fork 1
/
client_test.go
38 lines (31 loc) · 867 Bytes
/
client_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
package crossref
import (
"net/http"
"testing"
"time"
)
func TestNewClient(t *testing.T) {
want := Client{
mailto: "mail@example.com",
appname: "Crossref Go",
Client: http.Client{Timeout: 5 * time.Second},
}
got := NewClient("Crossref Go", "mail@example.com")
if got.mailto != want.mailto {
t.Errorf("\ngot: \n\t%v\nwant: \n\t%v", got.mailto, want.mailto)
}
if got.appname != want.appname {
t.Errorf("\ngot: \n\t%v\nwant: \n\t%v", got.appname, want.appname)
}
if got.Client.Timeout != want.Client.Timeout {
t.Errorf("\ngot: \n\t%v\nwant: \n\t%v", got.Client.Timeout, want.Client.Timeout)
}
}
func TestString(t *testing.T) {
client := NewClient("Crossref Go", "mail@example.com")
want := "App: Crossref Go, MailTo: mail@example.com"
got := client.String()
if got != want {
t.Errorf("\ngot: \n\t%v\nwant: \n\t%v", got, want)
}
}