убрал их репо test

main
parent 2709866cb7
commit 97f41f1c9f

1
.gitignore vendored

@ -19,3 +19,4 @@
# Go workspace file # Go workspace file
go.work go.work
/test

@ -12,6 +12,5 @@ require (
require ( require (
github.com/davecgh/go-spew v1.1.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/stretchr/objx v0.5.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect
) )

@ -3,6 +3,7 @@ package pic
import ( import (
//"log" //"log"
"testing" "testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
@ -12,7 +13,7 @@ func TestNewPicture(t *testing.T) {
assert.Equal(t, p.Album, "проверка", "должны быть одинаковыми") assert.Equal(t, p.Album, "проверка", "должны быть одинаковыми")
} }
func TestbaseName(t *testing.T) { func TestBaseName(t *testing.T) {
base := baseName("c:\\Проверка файла с каталогом\\test.jpg") base := baseName("c:\\Проверка файла с каталогом\\test.jpg")
assert.Equal(t, base, "test", "должны быть одинаковыми") assert.Equal(t, base, "test", "должны быть одинаковыми")

@ -53,3 +53,25 @@ func TestGetSmallGifs(t *testing.T) {
err = download(url, filepath.Join("test", filename)) err = download(url, filepath.Join("test", filename))
assert.Nil(t, err) assert.Nil(t, err)
} }
func BenchmarkDownload(b *testing.B) {
seadb, err := NewSeaDB(db)
if err != nil {
panic(err)
}
urls, err := seadb.SmallGifs()
if err != nil {
panic(err)
}
for _, url := range urls {
filename, err := getFilename(url)
if err != nil {
panic(err)
}
err = download(url, filepath.Join("test", filename))
if err != nil {
panic(err)
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 MiB

@ -3,7 +3,6 @@ package pic
import ( import (
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net/http" "net/http"
"os" "os"
"strings" "strings"
@ -58,7 +57,7 @@ func download(url string, filename string) error {
} }
_, err = sw.Download(fid, nil, func(r io.Reader) (err error) { _, err = sw.Download(fid, nil, func(r io.Reader) (err error) {
data, err := ioutil.ReadAll(r) data, err := io.ReadAll(r)
if err != nil { if err != nil {
return err return err
} }

Loading…
Cancel
Save