Total Lines | 23 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | package credentials |
||
2 | |||
3 | import ( |
||
4 | "errors" |
||
5 | "net/http" |
||
6 | "testing" |
||
7 | |||
8 | "github.com/stretchr/testify/assert" |
||
9 | ) |
||
10 | |||
11 | func TestURLCredential_updateCredential(t *testing.T) { |
||
12 | URLCredential := newURLCredential("http://127.0.0.1") |
||
13 | hookDo = func(fn func(req *http.Request) (*http.Response, error)) func(req *http.Request) (*http.Response, error) { |
||
14 | return func(req *http.Request) (*http.Response, error) { |
||
15 | return mockResponse(300, ``, errors.New("sdk test")) |
||
16 | } |
||
17 | } |
||
18 | accesskeyId, err := URLCredential.GetAccessKeyId() |
||
19 | // assert.NotNil(t, err) |
||
20 | assert.Equal(t, "refresh Ecs sts token err: sdk test", err.Error()) |
||
21 | assert.Equal(t, "", *accesskeyId) |
||
22 | |||
23 | assert.Equal(t, "credential_uri", *URLCredential.GetType()) |
||
24 | } |
||
25 |