Skip to content

Commit 34640bb

Browse files
Copilothsluoyz
andcommitted
Fix TestSavePolicyPreventsDuplicates to test adapter directly
Co-authored-by: hsluoyz <[email protected]>
1 parent 3128877 commit 34640bb

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

adapter_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -688,8 +688,10 @@ func TestSavePolicyPreventsDuplicates(t *testing.T) {
688688
t.Errorf("Expected SavePolicy() to be successful; got %v", err)
689689
}
690690

691-
// Try to add a duplicate via AddPolicy - should be prevented by unique index
692-
_, err = e.AddPolicy("alice", "data1", "read")
691+
// Try to add a duplicate directly via adapter (bypassing enforcer's in-memory check)
692+
// This should be prevented by the unique index
693+
adapter := a.(*adapter)
694+
err = adapter.AddPolicy("p", "p", []string{"alice", "data1", "read"})
693695
if err == nil {
694696
t.Error("Expected AddPolicy of duplicate to fail due to unique index, but it succeeded")
695697
}

0 commit comments

Comments
 (0)