INNER CODE UNIT · Go
TestAdapter
apache/casbin-mongodb-adapter · adapter_test.go:146
func TestAdapter(t *testing.T) {
initPolicy(t, getDbURL())
// Note: you don't need to look at the above code
// if you already have a working DB with policy inside.
// Now the DB has policy, so we can provide a normal use case.
// Create an adapter and an enforcer.
// NewEnforcer() will load the policy automatically.
a, err := NewAdapter(getDbURL())
if err != nil {
panic(err)
}
e, err := casbin.NewEnforcer("examples/rbac_model.conf", a)
if err != nil {
panic(err)
}