-
Notifications
You must be signed in to change notification settings - Fork 16
/
profitbricks_test.go
50 lines (45 loc) · 1.3 KB
/
profitbricks_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
46
47
48
49
50
package profitbricks
import (
"github.com/stretchr/testify/suite"
"testing"
)
type SuiteClient struct {
ClientBaseSuite
}
func Test_Client(t *testing.T) {
suite.Run(t, new(SuiteClient))
}
/*
func (s *SuiteClient) Test_Retry() {
called := 0
httpmock.RegisterResponder(http.MethodGet, `=~/?depth=10`,
func(*http.Request) (*http.Response, error) {
called++
switch called {
case 1:
rsp := httpmock.NewBytesResponse(http.StatusTooManyRequests, []byte{})
rsp.Header.Set("Retry-After", "1") // Overruled by RetryMaxWaitTime of 2 ns
return rsp, nil
case 2:
return httpmock.NewBytesResponse(http.StatusBadGateway, []byte{}), nil
case 3:
return httpmock.NewBytesResponse(http.StatusGatewayTimeout, []byte{}), nil
case 4:
// Regression test for missing Retry-After in header
rsp := httpmock.NewBytesResponse(http.StatusTooManyRequests, []byte{})
return rsp, nil
}
// More response code
return httpmock.NewBytesResponse(http.StatusOK, []byte{}), nil
},
)
s.c.SetRetryCount(3)
// slower that 2 nano seconds will result in a wait time of max int nano seconds (caused by internal normalization
// in go resty
s.c.SetRetryWaitTime(2 * time.Nanosecond)
s.c.SetRetryMaxWaitTime(2 * time.Nanosecond)
err := s.c.GetOK("/", nil)
s.Error(err)
s.Equal(4, called)
}
*/