-
Notifications
You must be signed in to change notification settings - Fork 4
/
delete_folder_test.go
99 lines (92 loc) · 2.61 KB
/
delete_folder_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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package wrike_test
import (
"fmt"
"net/http"
"testing"
"gotest.tools/assert"
wrike "github.com/AkihikoITOH/wrike.go"
)
var deletedFolderData = []byte(
`{
"kind": "folders",
"data":
[
{
"id": "IEAAAAAQI4AB5BGU",
"accountId": "IEAAAAAQ",
"title": "New title",
"createdDate": "2019-02-18T11:17:42Z",
"updatedDate": "2019-02-18T11:17:46Z",
"description": "New description",
"sharedIds":
[
"KUAAAAAQ"
],
"parentIds":
[
"IEAAAAAQI7777776"
],
"childIds":
[
"IEAAAAAQI4AB5BGV",
"IEAAAAAQI4AB5BGW"
],
"superParentIds":
[
],
"scope": "RbFolder",
"hasAttachments": false,
"permalink": "https://dev.wrke.io/open.htm?id=2000084",
"workflowId": "IEAAAAAQK777777Q",
"metadata":
[
{
"key": "testMetaKey",
"value": "testMetaValue"
}
],
"customFields":
[
{
"id": "IEAAAAAQJUAAAAAX",
"value": "testValue"
},
{
"id": "IEAAAAAQJUAAAAAY",
"value": "testValue"
}
],
"project":
{
"authorId": "KUAAAAAQ",
"ownerIds":
[
"KUAAAAAQ"
],
"status": "Green",
"startDate": "2019-02-18",
"endDate": "2019-02-25",
"createdDate": "2019-02-18T11:17:44Z"
}
}
]
}`)
func Example_deleteFolder() {
conf := wrike.NewConfig("wrike-access-token", "")
api := wrike.NewAPI(conf)
api.DeleteFolder("IEAAAAAQI4AB5BGU")
}
func TestDeleteFolder(t *testing.T) {
client := NewMockClient(deletedFolderData)
api := &wrike.API{Config: mockAPIConfig, HTTPClient: client}
folders, err := api.DeleteFolder("IEAAAAAQI4AB5BGU")
if err != nil {
fmt.Println(err.Error())
}
// Check request object
assert.Equal(t, client.Request.Method, http.MethodDelete)
assert.Equal(t, client.Request.URL.String(), "https://app-eu.wrike.com/api/v4/folders/IEAAAAAQI4AB5BGU")
assert.Equal(t, client.Request.Body, nil)
SharedRequestTests(t, client.Request)
assert.Equal(t, string(folders.Data[0].ID), "IEAAAAAQI4AB5BGU")
}