-
Notifications
You must be signed in to change notification settings - Fork 3
/
protect_test.go
42 lines (35 loc) · 995 Bytes
/
protect_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
package p4
import (
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func TestProtections_Protections(t *testing.T) {
var (
currentACL *ACL
newACL = &ACL{List: []*Permission{
{"super", false, "root", "*", "//...", "更新于: 2022-10-09 11:17, 更新人: tangyongqiang, 描述: 评审控制"},
{"write", true, "eyotang", "*", "//main/...", ""},
}}
)
conn, err := setup(t)
Convey("test Protections functions", t, func() {
So(err, ShouldBeNil)
Convey("List triggers", func() {
currentACL, err = conn.Protections()
So(err, ShouldBeNil)
So(len(currentACL.List), ShouldBeGreaterThanOrEqualTo, 0)
})
Convey("Preview permissions", func() {
content := newACL.String()
So(content, ShouldNotBeEmpty)
})
Convey("Write new permissions", func() {
_, err = conn.WriteProtections(newACL)
So(err, ShouldBeNil)
})
Convey("Restore old permissions", func() {
_, err = conn.WriteProtections(currentACL)
So(err, ShouldBeNil)
})
})
}