-
Notifications
You must be signed in to change notification settings - Fork 0
/
token_test.go
45 lines (36 loc) · 1.09 KB
/
token_test.go
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
38
39
40
41
42
43
44
45
package ziggy_test
import (
"context"
"testing"
"github.com/nickcorin/investec/mock"
"github.com/nickcorin/ziggy"
"github.com/stretchr/testify/suite"
)
type AccessTokenTestSuite struct {
suite.Suite
client *ziggy.Client
server *mock.Server
}
func (suite *AccessTokenTestSuite) SetupSuite() {
suite.server = mock.NewServer()
suite.client = ziggy.NewClientForTesting(suite.T(), suite.server.URL)
}
func (suite *AccessTokenTestSuite) TestClient_GetAccessToken() {
token, err := suite.client.GetAccessToken(context.TODO(),
ziggy.TokenScopeAccounts)
suite.Require().NoError(err)
suite.Require().NotNil(token)
testToken := ziggy.AccessToken{
Token: "Ms9OsZkyrhBZd5yQJgfEtiDy4t2c",
Type: ziggy.TokenTypeBearer,
ExpiresIn: 1799,
Scope: ziggy.TokenScopeAccounts,
}
suite.Require().Equal(testToken.Token, token.Token)
suite.Require().Equal(testToken.Type, token.Type)
suite.Require().Equal(testToken.ExpiresIn, token.ExpiresIn)
suite.Require().Equal(testToken.Scope, token.Scope)
}
func TestAccessTokenTestSuite(t *testing.T) {
suite.Run(t, new(AccessTokenTestSuite))
}