MCPcopy
hub / github.com/apache/casbin / TestDuplicateRuleInAdapter

Function TestDuplicateRuleInAdapter

persist/persist_test.go:38–53  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

36}
37
38func TestDuplicateRuleInAdapter(t *testing.T) {
39 e, _ := casbin.NewEnforcer("../examples/basic_model.conf")
40
41 _, _ = e.AddPolicy("alice", "data1", "read")
42 _, _ = e.AddPolicy("alice", "data1", "read")
43
44 testRuleCount(t, e.GetModel(), 1, "p", "p", "AddPolicy")
45
46 e.ClearPolicy()
47
48 // simulate adapter.LoadPolicy with duplicate rules
49 _ = persist.LoadPolicyArray([]string{"p", "alice", "data1", "read"}, e.GetModel())
50 _ = persist.LoadPolicyArray([]string{"p", "alice", "data1", "read"}, e.GetModel())
51
52 testRuleCount(t, e.GetModel(), 1, "p", "p", "LoadPolicyArray")
53}

Callers

nothing calls this directly

Calls 5

AddPolicyMethod · 0.95
GetModelMethod · 0.95
ClearPolicyMethod · 0.95
LoadPolicyArrayFunction · 0.92
testRuleCountFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…