webp_server_go/prefetch_test.go
BennyThink a67de53ae6
url with non-ascii fix, bump version
This commit has fixed issue reported in PR 57, add test case
2020-11-24 22:25:10 +08:00

30 lines
584 B
Go

// webp_server_go - prefetch_test.go
// 2020-11-10 09:27
// Benny <benny.think@gmail.com>
package main
import (
"github.com/stretchr/testify/assert"
"os"
"testing"
)
func TestPrefetchImages(t *testing.T) {
// single thread
fp := "./prefetch"
_ = os.Mkdir(fp, 0755)
prefetchImages("./pics", "./prefetch", "80")
count := fileCount("./prefetch")
assert.Equal(t, 7, count)
_ = os.RemoveAll(fp)
// concurrency
jobs = 2
_ = os.Mkdir(fp, 0755)
prefetchImages("./pics", "./prefetch", "80")
count = fileCount("./prefetch")
assert.Equal(t, 5, count)
_ = os.RemoveAll(fp)
}