-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdisk_test.go
62 lines (53 loc) · 1.81 KB
/
disk_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
62
package disk
import (
"context"
"net/http"
"testing"
"github.com/stretchr/testify/assert"
)
func TestClientGetDiskInfo(t *testing.T) {
h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
assert.NotEmpty(t, r.Header.Get("Authorization"))
assert.Equal(t, "OAuth token", r.Header.Get("Authorization"))
w.Write([]byte(`
{
"unlimited_autoupload_enabled": false,
"max_file_size": 53687091200,
"total_space": 1190242811904,
"is_paid": true,
"used_space": 664410431972,
"system_folders": {
"odnoklassniki": "disk:/Социальные сети/Одноклассники",
"google": "disk:/Социальные сети/Google+",
"instagram": "disk:/Социальные сети/Instagram",
"vkontakte": "disk:/Социальные сети/ВКонтакте",
"mailru": "disk:/Социальные сети/Мой Мир",
"downloads": "disk:/Загрузки/",
"applications": "disk:/Приложения",
"facebook": "disk:/Социальные сети/Facebook",
"social": "disk:/Социальные сети/",
"screenshots": "disk:/Скриншоты/",
"photostream": "disk:/Фотокамера/"
},
"user": {
"country": "ru",
"login": "user",
"display_name": "User Name",
"uid": "12345678"
},
"revision": 1602851010832695
}`))
})
client := mockedHttpClient(h)
disk, err := client.DiskInfo(context.Background())
// check response data
assert.Nil(t, err)
assert.Equal(t, true, disk.IsPaid)
assert.Equal(t, 53687091200, disk.MaxFileSize)
assert.Equal(t, 1190242811904, disk.TotalSpace)
assert.Equal(t, "User Name", disk.User.DisplayName)
// check types
assert.IsType(t, Disk{}.IsPaid, disk.IsPaid)
assert.IsType(t, Disk{}.User, disk.User)
assert.IsType(t, Disk{}.SystemFolders, disk.SystemFolders)
}