(t *testing.T, mData, mExpected string)
| 131 | } |
| 132 | |
| 133 | func 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 | } |
no test coverage detected
searching dependent graphs…