29 lines
664 B
Go
29 lines
664 B
Go
![]() |
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")
|
||
|
}
|