-
Notifications
You must be signed in to change notification settings - Fork 315
Expand file tree
/
Copy pathrole_test.go
More file actions
37 lines (29 loc) · 861 Bytes
/
role_test.go
File metadata and controls
37 lines (29 loc) · 861 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package oauth_test
import (
"github.com/RichardKnop/go-oauth2-server/models"
"github.com/RichardKnop/go-oauth2-server/oauth"
"github.com/RichardKnop/go-oauth2-server/oauth/roles"
"github.com/stretchr/testify/assert"
)
func (suite *OauthTestSuite) TestFindRoleByID() {
var (
role *models.OauthRole
err error
)
// Let's try to find a role by a bogus ID
role, err = suite.service.FindRoleByID("bogus")
// Role should be nil
assert.Nil(suite.T(), role)
// Correct error should be returned
if assert.NotNil(suite.T(), err) {
assert.Equal(suite.T(), oauth.ErrRoleNotFound, err)
}
// Now let's pass a valid ID
role, err = suite.service.FindRoleByID(roles.User)
// Error should be nil
assert.Nil(suite.T(), err)
// Correct role should be returned
if assert.NotNil(suite.T(), role) {
assert.Equal(suite.T(), roles.User, role.ID)
}
}