MCPcopy Create free account
hub / github.com/apache/casbin-server / newTestEngine

Function newTestEngine

server/test_util.go:31–51  ·  view source on GitHub ↗
(t *testing.T, from, connectStr string, modelLoc string)

Source from the content-addressed store, hash-verified

29}
30
31func newTestEngine(t *testing.T, from, connectStr string, modelLoc string) *testEngine {
32 s := NewServer()
33 ctx := context.Background()
34
35 _, err := s.NewAdapter(ctx, &pb.NewAdapterRequest{DriverName: from, ConnectString: connectStr})
36 if err != nil {
37 t.Fatal(err)
38 }
39
40 modelText, err := ioutil.ReadFile(modelLoc)
41 if err != nil {
42 t.Fatal(err)
43 }
44
45 resp, err := s.NewEnforcer(ctx, &pb.NewEnforcerRequest{ModelText: string(modelText), AdapterHandle: 0, EnableAcceptJsonRequest: true})
46 if err != nil {
47 t.Fatal(err)
48 }
49
50 return &testEngine{s: s, ctx: ctx, h: resp.Handler}
51}

Callers 7

TestGetListFunction · 0.85
TestGetPolicyAPIFunction · 0.85
TestModifyPolicyAPIFunction · 0.85
TestRoleAPIFunction · 0.85
TestPermissionAPIFunction · 0.85
TestRoleDomainAPIFunction · 0.85

Calls 3

NewAdapterMethod · 0.95
NewEnforcerMethod · 0.95
NewServerFunction · 0.85

Tested by 7

TestGetListFunction · 0.68
TestGetPolicyAPIFunction · 0.68
TestModifyPolicyAPIFunction · 0.68
TestRoleAPIFunction · 0.68
TestPermissionAPIFunction · 0.68
TestRoleDomainAPIFunction · 0.68