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

Function testModelToText

model/model_test.go:133–161  ·  view source on GitHub ↗
(t *testing.T, mData, mExpected string)

Source from the content-addressed store, hash-verified

131}
132
133func testModelToText(t *testing.T, mData, mExpected string) {
134 m := NewModel()
135 data := map[string]string{
136 "r": "sub, obj, act",
137 "p": "sub, obj, act",
138 "e": "some(where (p.eft == allow))",
139 "m": mData,
140 }
141 expected := map[string]string{
142 "r": "sub, obj, act",
143 "p": "sub, obj, act",
144 "e": constant.AllowOverrideEffect,
145 "m": mExpected,
146 }
147 addData := func(ptype string) {
148 m.AddDef(ptype, ptype, data[ptype])
149 }
150 for ptype := range data {
151 addData(ptype)
152 }
153 newM := NewModel()
154 print(m.ToText())
155 _ = newM.LoadModelFromText(m.ToText())
156 for ptype := range data {
157 if newM[ptype][ptype].Value != expected[ptype] {
158 t.Errorf("\"%s\" assertion value changed, current value: %s, it should be: %s", ptype, newM[ptype][ptype].Value, expected[ptype])
159 }
160 }
161}

Callers 1

TestModelToTestFunction · 0.85

Calls 4

AddDefMethod · 0.95
ToTextMethod · 0.95
LoadModelFromTextMethod · 0.95
NewModelFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…