webp_server_go/prefetch_test.go
Benny 428192275b
choose webp or png feature (#70)
* support webp_bigger header, add test cases

* fix test case
2021-02-12 16:13:13 +08:00

35 lines
681 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, 8, count)
_ = os.RemoveAll(fp)
// concurrency
jobs = 2
_ = os.Mkdir(fp, 0755)
prefetchImages("./pics", "./prefetch", "80")
count = fileCount("./prefetch")
assert.Equal(t, 6, count)
_ = os.RemoveAll(fp)
}
func TestBadPrefetch(t *testing.T) {
jobs = 1
prefetchImages("./pics2", "./prefetch", "80")
}