forked from gphotosuploader/google-photos-api-client-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient_test.go
48 lines (40 loc) · 1.18 KB
/
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
39
40
41
42
43
44
45
46
47
48
package gphotos_test
import (
"net/http"
"testing"
gphotos "github.com/gphotosuploader/google-photos-api-client-go/v3"
)
func TestNewClient(t *testing.T) {
t.Run("Should success with httpClient", func(t *testing.T) {
_, err := gphotos.NewClient(http.DefaultClient)
if err != nil {
t.Fatalf("error was not expected at this point: %s", err)
}
})
t.Run("Should fail without httpClient", func(t *testing.T) {
_, err := gphotos.NewClient(nil)
if err == nil {
t.Errorf("error was expected but not produced")
}
})
}
func TestNewClientWithBaseURL(t *testing.T) {
t.Run("Should success", func(t *testing.T) {
_, err := gphotos.NewClientWithBaseURL(http.DefaultClient, "https://foo.bar")
if err != nil {
t.Fatalf("error was not expected at this point: %s", err)
}
})
t.Run("Should fail without httpClient", func(t *testing.T) {
_, err := gphotos.NewClientWithBaseURL(nil, "https://foo.bar")
if err == nil {
t.Errorf("error was expected but not produced")
}
})
t.Run("Should fail without baseURL", func(t *testing.T) {
_, err := gphotos.NewClientWithBaseURL(http.DefaultClient, "")
if err == nil {
t.Errorf("error was expected but not produced")
}
})
}