This commit is contained in:
admju
2024-09-02 07:09:46 +00:00
parent 00d92b73f8
commit 4ae5926b01
40 changed files with 1711 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
package utils
// https://pkg.go.dev/github.com/stretchr/testify/assert#Nilf
import (
"path/filepath"
"testing"
"github.com/stretchr/testify/assert"
"github.com/jarcoal/httpmock"
)
func TestDownload(t *testing.T){
httpmock.Activate()
defer httpmock.DeactivateAndReset()
url := "http://test.download.com"
httpmock.RegisterResponder("GET", url,
httpmock.NewStringResponder(200, `CONTENU_URL`))
dest := filepath.Join(TEST_DEST_DIR, "url")
err := DownloadFromUrl(dest, url, 777)
assert.Nilf(t, err, "error message %s", url)
assert.FileExists(t, dest, "DownloadFromUrl error")
}