MCPcopy Create free account
hub / github.com/cloudreve/cloudreve / TestHTTPClient_Request

Function TestHTTPClient_Request

pkg/request/request_test.go:55–89  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

53}
54
55func 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
91func TestResponse_GetResponse(t *testing.T) {
92 asserts := assert.New(t)

Callers

nothing calls this directly

Calls 11

NewClientDeprecatedFunction · 0.85
WithSlaveMetaFunction · 0.85
WithTimeoutFunction · 0.85
WithCredentialFunction · 0.85
WithoutHeaderFunction · 0.85
WithContentLengthFunction · 0.85
WithEndpointFunction · 0.85
WithContextFunction · 0.70
NewMethod · 0.65
RequestMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected