TestExplainWithoutConfig tests that Explain returns error when config is not set.
(t *testing.T)
| 25 | |
| 26 | // TestExplainWithoutConfig tests that Explain returns error when config is not set. |
| 27 | func TestExplainWithoutConfig(t *testing.T) { |
| 28 | e, err := NewEnforcer("examples/basic_model.conf", "examples/basic_policy.csv") |
| 29 | if err != nil { |
| 30 | t.Fatal(err) |
| 31 | } |
| 32 | |
| 33 | _, err = e.Explain("alice", "data1", "read") |
| 34 | if err == nil { |
| 35 | t.Error("Expected error when AI config is not set") |
| 36 | } |
| 37 | if !strings.Contains(err.Error(), "AI config not set") { |
| 38 | t.Errorf("Expected 'AI config not set' error, got: %v", err) |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | // TestExplainWithMockAPI tests Explain with a mock OpenAI-compatible API. |
| 43 | func TestExplainWithMockAPI(t *testing.T) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…