Skip to content

Commit

Permalink
opt: optimize test case of SoftDelete
Browse files Browse the repository at this point in the history
  • Loading branch information
JalinWang committed Jun 27, 2022
1 parent c77c05d commit 8ef2a8a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion adapter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ func TestSoftDelete(t *testing.T) {
}

// Start preparing
db, err := gorm.Open(mysql.Open("root:@tcp(127.0.0.1:3306)/casbin"), &gorm.Config{})
db, err := gorm.Open(mysql.Open("root:@tcp(127.0.0.1:3306)/casbin?parseTime=true"), &gorm.Config{})
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -304,6 +304,12 @@ func TestSoftDelete(t *testing.T) {
{"carol", "data1", "read"},
})

res := TestCasbinRule{}
err = a.db.Unscoped().Find(&res, "ptype = ? and v0 = ? and v1 = ? and v2 = ?", "p", "bob", "data2", "write").Error
assert.Nil(t, err)
assert.NotNil(t, res.DeletedAt)
log.Print("SoftDeletedRecord: ", res)

// Test LoadFilteredPolicy
e.ClearPolicy()
err = a.LoadFilteredPolicy(e.GetModel(), Filter{
Expand Down

0 comments on commit 8ef2a8a

Please sign in to comment.