INNER CODE UNIT · Go

TestNewAdapterWithCollectionName

apache/casbin-mongodb-adapter · adapter_test.go:465

func TestNewAdapterWithCollectionName(t *testing.T) {
	uri := getDbURL()
	if !strings.HasPrefix(uri, "mongodb+srv://") && !strings.HasPrefix(uri, "mongodb://") {
		uri = fmt.Sprint("mongodb://" + uri)
	}
	mongoClientOption := mongooptions.Client().ApplyURI(uri)
	databaseName := "casbin_custom"
	collectionName := "casbin_rule_custom"
	_, err := NewAdapterWithCollectionName(mongoClientOption, databaseName, collectionName)
	if err != nil {
		panic(err)
	}
}

func TestNewAdapterByDB(t *testing.T) {
	uri := getDbURL()
	if !strings.HasPrefix(uri, "mongodb+srv://") && !strings.HasPrefix(uri, "mongodb://") {
		uri = fmt.Sprint("mongodb://" + uri)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…