forked from ggordan/go-onedrive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
onedrive_test.go
52 lines (43 loc) · 949 Bytes
/
onedrive_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
package onedrive
import (
"io/ioutil"
"net/http"
"net/http/httptest"
"testing"
"gotest.tools/assert"
)
var (
mux *http.ServeMux
server *httptest.Server
oneDrive *OneDrive
)
func setup() {
mux = http.NewServeMux()
server = httptest.NewServer(mux)
oneDrive = New(http.DefaultClient)
oneDrive.BaseURL = server.URL
}
func teardown() {
server.Close()
}
func fileWrapperHandler(file string, status int) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(status)
b, err := ioutil.ReadFile(file)
if err != nil {
panic(err)
}
w.Write(b)
}
}
func TestOneDrive_New(t *testing.T) {
client := http.DefaultClient
od := New(client)
assert.Equal(t, od.Client, client)
assert.Assert(t, od.Drives != nil)
assert.Assert(t, od.Items != nil)
assert.Assert(t, od.Sites != nil)
assert.Assert(t, od.SearchService != nil)
_, isSite := od.Sites.(siteService)
assert.Assert(t, isSite)
}