mirror of
https://github.com/woodchen-ink/webp_server_go.git
synced 2025-07-18 13:42:02 +08:00
fix one test case bug, remove one easy to fail test case,
improve test case stability by adding timeout to 60s
This commit is contained in:
parent
a67de53ae6
commit
1056963bb2
@ -22,6 +22,7 @@ func TestWebpEncoder(t *testing.T) {
|
||||
// test error
|
||||
err := webpEncoder("./pics/empty.jpg", webp, 80, true, nil)
|
||||
assert.NotNil(t, err)
|
||||
_ = os.Remove(webp)
|
||||
}
|
||||
|
||||
func TestNonImage(t *testing.T) {
|
||||
@ -29,14 +30,10 @@ func TestNonImage(t *testing.T) {
|
||||
// test error
|
||||
var err = webpEncoder("./pics/empty.jpg", webp, 80, true, nil)
|
||||
assert.NotNil(t, err)
|
||||
_ = os.Remove(webp)
|
||||
|
||||
}
|
||||
|
||||
func TestWriteFail(t *testing.T) {
|
||||
// test permission denied
|
||||
var webp = "/123.webp"
|
||||
var err = webpEncoder("./pics/png.jpg", webp, 80, true, nil)
|
||||
assert.NotNil(t, err)
|
||||
}
|
||||
func walker() []string {
|
||||
var list []string
|
||||
_ = filepath.Walk("./pics", func(path string, info os.FileInfo, err error) error {
|
||||
|
@ -116,7 +116,7 @@ func TestChanErr(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetRemoteImageInfo(t *testing.T) {
|
||||
url := "http://github.com/favicon.ico"
|
||||
url := "https://github.com/favicon.ico"
|
||||
statusCode, etag := getRemoteImageInfo(url)
|
||||
assert.NotEqual(t, "", etag)
|
||||
assert.Equal(t, statusCode, http.StatusOK)
|
||||
|
@ -121,7 +121,7 @@ func setupParam() {
|
||||
func requestToServer(url string, app *fiber.App, ua string) (*http.Response, []byte) {
|
||||
req := httptest.NewRequest("GET", url, nil)
|
||||
req.Header.Set("User-Agent", ua)
|
||||
resp, _ := app.Test(req)
|
||||
resp, _ := app.Test(req, 60000)
|
||||
data, _ := ioutil.ReadAll(resp.Body)
|
||||
return resp, data
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user