This is an automated email from the ASF dual-hosted git repository.
hsluoyz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/casbin-ent-adapter.git
The following commit(s) were added to refs/heads/master by this push:
new dba7bd2 fix(test): count the g rule in the unique index baseline
dba7bd2 is described below
commit dba7bd2d8b0087a8ef5a8e98cb171b0f8241cd10
Author: Yang Luo <[email protected]>
AuthorDate: Thu Aug 6 22:30:33 2026 +0800
fix(test): count the g rule in the unique index baseline
---
adapter_test.go | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/adapter_test.go b/adapter_test.go
index 21d58d5..4aee694 100644
--- a/adapter_test.go
+++ b/adapter_test.go
@@ -267,10 +267,11 @@ func testFilteredPolicy(t *testing.T, a *Adapter) {
// testUniqueIndex covers the index on (ptype, v0..v5): storing a rule that is
// already there is a no-op rather than a second row or an error.
func testUniqueIndex(t *testing.T, a *Adapter) {
- // initAdapter has just stored the four rules of rbac_policy.csv.
+ // initAdapter has just stored the five rules of rbac_policy.csv: four p
+ // rules and one g rule.
count, err := a.client.CasbinRule.Query().Count(a.ctx)
assert.Nil(t, err)
- assert.Equal(t, 4, count)
+ assert.Equal(t, 5, count)
// Re-adding a stored rule is what a replica does when its in-memory
model
// has not caught up with another writer.
@@ -283,9 +284,11 @@ func testUniqueIndex(t *testing.T, a *Adapter) {
{"eve", "data3", "read"},
}))
+ // Only eve is new: the duplicates of alice's rule and of eve's own rule
+ // inside the batch collapse onto the same row.
count, err = a.client.CasbinRule.Query().Count(a.ctx)
assert.Nil(t, err)
- assert.Equal(t, 5, count)
+ assert.Equal(t, 6, count)
eve, err :=
a.client.CasbinRule.Query().Where(casbinrule.V0EQ("eve")).Count(a.ctx)
assert.Nil(t, err)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]