|
| 1 | +// Copyright 2017 The casbin Authors. All Rights Reserved. |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +package xormadapter |
| 16 | + |
| 17 | +import ( |
| 18 | + "testing" |
| 19 | + |
| 20 | + "github.com/casbin/casbin/v3/persist" |
| 21 | +) |
| 22 | + |
| 23 | +// TestAdapterInterface verifies that Adapter implements persist.Adapter interface for Casbin v3 |
| 24 | +func TestAdapterInterface(t *testing.T) { |
| 25 | + var _ persist.Adapter = (*Adapter)(nil) |
| 26 | +} |
| 27 | + |
| 28 | +// TestCasbinV3Compatibility verifies that the adapter type is compatible with Casbin v3 |
| 29 | +func TestCasbinV3Compatibility(t *testing.T) { |
| 30 | + // Create a dummy adapter (won't connect to DB in this test) |
| 31 | + a := &Adapter{ |
| 32 | + driverName: "mysql", |
| 33 | + dataSourceName: "root:@tcp(127.0.0.1:3306)/", |
| 34 | + dbSpecified: false, |
| 35 | + tableName: "casbin_rule", |
| 36 | + } |
| 37 | + |
| 38 | + // This verifies the adapter implements persist.Adapter interface correctly |
| 39 | + // If LoadPolicy method was missing, this would fail to compile |
| 40 | + var adapter persist.Adapter = a |
| 41 | + |
| 42 | + // Verify the type assertion works |
| 43 | + if adapter == nil { |
| 44 | + t.Fatal("Adapter should not be nil") |
| 45 | + } |
| 46 | + |
| 47 | + t.Log("Successfully verified Adapter implements persist.Adapter for Casbin v3") |
| 48 | +} |
0 commit comments