Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: import the testing package in the manager_test_helper.go #145

Closed
wants to merge 8 commits into from
8 changes: 4 additions & 4 deletions manager_all_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ func connectMEM() {
func TestManagers(t *testing.T) {
t.Run("type=get errors", func(t *testing.T) {
for k, s := range managers {
t.Run("manager="+k, TestHelperGetErrors(s))
t.Run("manager="+k, testHelperGetErrors(s))
}
})

t.Run("type=CRUD", func(t *testing.T) {
for k, s := range managers {
t.Run(fmt.Sprintf("manager=%s", k), TestHelperCreateGetDelete(s))
t.Run(fmt.Sprintf("manager=%s", k), testHelperCreateGetDelete(s))
}
})

Expand All @@ -56,8 +56,8 @@ func TestManagers(t *testing.T) {
"postgres": managers["postgres"],
"mysql": managers["mysql"],
} {
t.Run(fmt.Sprintf("manager=%s", k), TestHelperFindPoliciesForSubject(k, s))
t.Run(fmt.Sprintf("manager=%s", k), TestHelperFindPoliciesForResource(k, s))
t.Run(fmt.Sprintf("manager=%s", k), testHelperFindPoliciesForSubject(k, s))
t.Run(fmt.Sprintf("manager=%s", k), testHelperFindPoliciesForResource(k, s))
}
})
}
11 changes: 6 additions & 5 deletions manager_test_helper.go → manager_helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@
* @license Apache-2.0
*/

package ladon
package ladon_test

import (
"fmt"
"reflect"
"testing"

. "github.com/ory/ladon"
"github.com/pborman/uuid"
"github.com/pkg/errors"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -255,7 +256,7 @@ var testPolicies = []*DefaultPolicy{
},
}

func TestHelperFindPoliciesForSubject(k string, s Manager) func(t *testing.T) {
func testHelperFindPoliciesForSubject(k string, s Manager) func(t *testing.T) {
return func(t *testing.T) {
for _, c := range testPolicies {
t.Run(fmt.Sprintf("create=%s", k), func(t *testing.T) {
Expand Down Expand Up @@ -291,7 +292,7 @@ func TestHelperFindPoliciesForSubject(k string, s Manager) func(t *testing.T) {
}
}

func TestHelperFindPoliciesForResource(k string, s Manager) func(t *testing.T) {
func testHelperFindPoliciesForResource(k string, s Manager) func(t *testing.T) {
return func(t *testing.T) {
for _, c := range testPolicies {
t.Run(fmt.Sprintf("create=%s", k), func(t *testing.T) {
Expand Down Expand Up @@ -368,7 +369,7 @@ func testEq(a, b []string) error {
return nil
}

func TestHelperGetErrors(s Manager) func(t *testing.T) {
func testHelperGetErrors(s Manager) func(t *testing.T) {
return func(t *testing.T) {
_, err := s.Get(uuid.New())
assert.Error(t, err)
Expand All @@ -378,7 +379,7 @@ func TestHelperGetErrors(s Manager) func(t *testing.T) {
}
}

func TestHelperCreateGetDelete(s Manager) func(t *testing.T) {
func testHelperCreateGetDelete(s Manager) func(t *testing.T) {
return func(t *testing.T) {
for i, c := range TestManagerPolicies {
t.Run(fmt.Sprintf("case=%d/id=%s/type=create", i, c.GetID()), func(t *testing.T) {
Expand Down