forked from snowlyg/iris-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
permissions_test.go
55 lines (42 loc) · 1.24 KB
/
permissions_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
package main
import (
"fmt"
"testing"
"github.com/kataras/iris/v12"
)
func TestPermissions(t *testing.T) {
url := "/v1/admin/permissions"
getMore(t, url, iris.StatusOK, true, "操作成功", nil)
}
func TestPermissionCreate(t *testing.T) {
oj := map[string]interface{}{
"name": "test_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/permissions"
create(t, url, oj, iris.StatusOK, true, "操作成功", data)
}
func TestPermissionUpdate(t *testing.T) {
oj := map[string]interface{}{
"name": "update_permission",
"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/permissions/%d"
update(t, fmt.Sprintf(url, testPerm.ID), oj, iris.StatusOK, true, "操作成功", data)
}
func TestPermissionDelete(t *testing.T) {
url := "/v1/admin/permissions/%d"
delete(t, fmt.Sprintf(url, testPerm.ID), iris.StatusOK, true, "删除成功", nil)
}