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

main
parent 2709866cb7
commit 97f41f1c9f

1
.gitignore vendored

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

@ -12,6 +12,5 @@ require (
require (
github.com/davecgh/go-spew v1.1.1 // 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
)

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

@ -53,3 +53,25 @@ func TestGetSmallGifs(t *testing.T) {
err = download(url, filepath.Join("test", filename))
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 (
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
"strings"
@ -58,7 +57,7 @@ func download(url string, filename string) 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 {
return err
}

Loading…
Cancel
Save