(t *testing.T)
| 53 | } |
| 54 | |
| 55 | func TestHTTPClient_Request(t *testing.T) { |
| 56 | asserts := assert.New(t) |
| 57 | client := NewClientDeprecated(WithSlaveMeta("test")) |
| 58 | |
| 59 | // 正常 |
| 60 | { |
| 61 | resp := client.Request( |
| 62 | "POST", |
| 63 | "/test", |
| 64 | strings.NewReader(""), |
| 65 | WithTimeout(time.Duration(1)*time.Microsecond), |
| 66 | WithCredential(auth.HMACAuth{SecretKey: []byte("123")}, 10), |
| 67 | WithoutHeader([]string{"origin", "origin"}), |
| 68 | ) |
| 69 | asserts.Error(resp.Err) |
| 70 | asserts.Nil(resp.Response) |
| 71 | } |
| 72 | |
| 73 | // 正常 带有ctx |
| 74 | { |
| 75 | resp := client.Request( |
| 76 | "GET", |
| 77 | "http://cloudreveisnotexist.com", |
| 78 | strings.NewReader(""), |
| 79 | WithContentLength(0), |
| 80 | WithEndpoint("http://cloudreveisnotexist.com"), |
| 81 | WithTimeout(time.Duration(1)*time.Microsecond), |
| 82 | WithCredential(auth.HMACAuth{SecretKey: []byte("123")}, 10), |
| 83 | WithContext(context.Background()), |
| 84 | ) |
| 85 | asserts.Error(resp.Err) |
| 86 | asserts.Nil(resp.Response) |
| 87 | } |
| 88 | |
| 89 | } |
| 90 | |
| 91 | func TestResponse_GetResponse(t *testing.T) { |
| 92 | asserts := assert.New(t) |
nothing calls this directly
no test coverage detected