Test: new changes in 3.4.0

This commit is contained in:
HFO4
2021-11-20 16:59:29 +08:00
parent 532bff820a
commit 9056ef9171
6 changed files with 112 additions and 5 deletions

View File

@@ -3,6 +3,7 @@ package request
import (
"context"
"errors"
"github.com/cloudreve/Cloudreve/v3/pkg/cache"
"io"
"io/ioutil"
"net/http"
@@ -54,16 +55,19 @@ func TestWithContext(t *testing.T) {
func TestHTTPClient_Request(t *testing.T) {
asserts := assert.New(t)
client := HTTPClient{}
client := NewClient(WithSlaveMeta("test"))
// 正常
{
resp := client.Request(
"GET",
"http://cloudreveisnotexist.com",
"POST",
"/test",
strings.NewReader(""),
WithContentLength(0),
WithEndpoint("http://cloudreveisnotexist.com"),
WithTimeout(time.Duration(1)*time.Microsecond),
WithCredential(auth.HMACAuth{SecretKey: []byte("123")}, 10),
WithoutHeader([]string{"origin", "origin"}),
)
asserts.Error(resp.Err)
asserts.Nil(resp.Response)
@@ -224,3 +228,11 @@ func TestNopRSCloser_SetFirstFakeChunk(t *testing.T) {
rsc.SetContentLength(20)
asserts.EqualValues(20, rsc.status.Size)
}
func TestBlackHole(t *testing.T) {
a := assert.New(t)
cache.Set("setting_reset_after_upload_failed", "true", 0)
a.NotPanics(func() {
BlackHole(strings.NewReader("TestBlackHole"))
})
}