forked from snowlyg/iris-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroles_test.go
60 lines (46 loc) · 1.25 KB
/
roles_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
package main
import (
"fmt"
"testing"
"github.com/kataras/iris"
)
// 后台账号列表
func TestRoles(t *testing.T) {
url := "/v1/admin/roles"
getMore(t, url, iris.StatusOK, true, "操作成功", nil)
}
// 创建角色
func TestRoleCreate(t *testing.T) {
oj := map[string]interface{}{
"name": "create_role",
"display_name": "create_display_name",
"description": "create_description",
}
data := map[string]interface{}{
"Name": oj["name"],
"DisplayName": oj["display_name"],
"Description": oj["description"],
}
url := "/v1/admin/roles"
create(t, url, oj, iris.StatusOK, true, "操作成功", data)
}
// 更新角色
func TestRoleUpdate(t *testing.T) {
oj := map[string]interface{}{
"name": "test_update_role",
"display_name": "update_display_name",
"description": "update_description",
}
data := map[string]interface{}{
"Name": oj["name"],
"DisplayName": oj["display_name"],
"Description": oj["description"],
}
url := "/v1/admin/roles/%d"
update(t, fmt.Sprintf(url, testRole.ID), oj, iris.StatusOK, true, "操作成功", data)
}
// 删除角色
func TestRoleDelete(t *testing.T) {
url := "/v1/admin/roles/%d"
delete(t, fmt.Sprintf(url, testRole.ID), iris.StatusOK, true, "删除成功", nil)
}