MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / TestUserPermissionFromRole

Function TestUserPermissionFromRole

types/account_test.go:26–58  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

24)
25
26func TestUserPermissionFromRole(t *testing.T) {
27 Convey("test marshal/unmarshal json", t, func() {
28 jsonBytes, err := json.Marshal(Read)
29 So(err, ShouldBeNil)
30 So(jsonBytes, ShouldResemble, []byte(`"Read"`))
31 var r UserPermissionRole
32 So(r, ShouldEqual, Void)
33 err = json.Unmarshal([]byte(`"Write"`), &r)
34 So(err, ShouldBeNil)
35 So(r, ShouldEqual, Write)
36 err = r.UnmarshalJSON([]byte(`"Read,Write"`))
37 So(err, ShouldBeNil)
38 So(r, ShouldEqual, ReadWrite)
39 })
40 Convey("test string/from string", t, func() {
41 var r UserPermissionRole
42 So(r, ShouldEqual, Void)
43 r.FromString(Read.String())
44 So(r, ShouldEqual, Read)
45 r.FromString(Void.String())
46 So(r, ShouldEqual, Void)
47 r.FromString(ReadWrite.String())
48 So(r, ShouldEqual, ReadWrite)
49 r.FromString(Admin.String())
50 So(r, ShouldEqual, Admin)
51
52 // tricky case
53 trickyStr := "Write,Super"
54 r.FromString(trickyStr)
55 So(r, ShouldEqual, Write|Super)
56 So(r.String(), ShouldEqual, trickyStr)
57 })
58}
59
60func TestUserPermission(t *testing.T) {
61 Convey("nil protect", t, func() {

Callers

nothing calls this directly

Calls 6

UnmarshalJSONMethod · 0.95
FromStringMethod · 0.95
StringMethod · 0.95
MarshalMethod · 0.80
UnmarshalMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected