chore(grequests): update grequests to v2
This commit is contained in:
parent
a88da88a47
commit
00bf1820f1
5 changed files with 18 additions and 13 deletions
|
@ -1,6 +1,7 @@
|
|||
package downloader_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
|
@ -37,7 +38,7 @@ func TestDownload(t *testing.T) {
|
|||
ctx := downloader.NewContext(filename, server.URL)
|
||||
defer os.Remove(filename)
|
||||
|
||||
err := ctx.Download()
|
||||
err := ctx.Download(context.Background())
|
||||
if err != nil {
|
||||
t.Errorf("expected no error, got %v", err)
|
||||
}
|
||||
|
@ -49,7 +50,7 @@ func TestDownload(t *testing.T) {
|
|||
|
||||
t.Run("InvalidURL", func(t *testing.T) {
|
||||
ctx := downloader.NewContext("test_invalid_url.txt", "http://invalid.url")
|
||||
err := ctx.Download()
|
||||
err := ctx.Download(context.Background())
|
||||
|
||||
if err == nil || err.Error() != "invalid url" {
|
||||
t.Errorf("expected invalid url error, got %v", err)
|
||||
|
@ -63,7 +64,8 @@ func TestDownload(t *testing.T) {
|
|||
"https://self-signed.badssl.com/", // Example URL that can be used
|
||||
)
|
||||
|
||||
if err := ctx.Download(); err == nil || err.Error() != "certificate from unknown authority" {
|
||||
err := ctx.Download(context.Background())
|
||||
if err == nil || err.Error() != "certificate from unknown authority" {
|
||||
t.Errorf("expected certificate from unknown authority error, got %v", err)
|
||||
}
|
||||
})
|
||||
|
@ -77,7 +79,7 @@ func TestDownload(t *testing.T) {
|
|||
|
||||
ctx := downloader.NewContext("test_not_found.txt", server.URL)
|
||||
|
||||
if err := ctx.Download(); err == nil || err.Error() != "invalid url" {
|
||||
if err := ctx.Download(context.Background()); err == nil || err.Error() != "invalid url" {
|
||||
t.Errorf("expected invalid url error, got %v", err)
|
||||
}
|
||||
})
|
||||
|
@ -91,7 +93,8 @@ func TestDownload(t *testing.T) {
|
|||
|
||||
ctx := downloader.NewContext("test_restricted_access.txt", server.URL)
|
||||
|
||||
if err := ctx.Download(); err == nil || err.Error() != "restricted access (credentials required)" {
|
||||
err := ctx.Download(context.Background())
|
||||
if err == nil || err.Error() != "restricted access (credentials required)" {
|
||||
t.Errorf("expected restricted access error, got %v", err)
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue