mirror of
https://github.com/woodchen-ink/webp_server_go.git
synced 2025-07-18 05:32:02 +08:00
* recover middleware * simplify Atoi * metadata data prototype * InterestingAttention * resize itself * Bump version to 0.9.4 Added some comments Removed String() for Extraparams * Add metadata test * Fix CI * Remove unnecessary tests * Update file count * use t.Run to get test case --------- Co-authored-by: n0vad3v <n0vad3v@riseup.net>
49 lines
951 B
Go
49 lines
951 B
Go
package helper
|
|
|
|
import (
|
|
"testing"
|
|
"webp_server_go/config"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestMain(m *testing.M) {
|
|
config.ConfigPath = "../config.json"
|
|
config.LoadConfig()
|
|
m.Run()
|
|
config.ConfigPath = "config.json"
|
|
|
|
}
|
|
|
|
func TestFileCount(t *testing.T) {
|
|
// test helper dir
|
|
count := FileCount("./")
|
|
assert.Equal(t, int64(4), count)
|
|
}
|
|
|
|
func TestImageExists(t *testing.T) {
|
|
t.Run("file not exists", func(t *testing.T) {
|
|
assert.False(t, ImageExists("dgyuaikdsa"))
|
|
})
|
|
|
|
// TODO: how to test lock?
|
|
|
|
t.Run("test dir", func(t *testing.T) {
|
|
assert.False(t, ImageExists("/tmp"))
|
|
})
|
|
|
|
t.Run("test file", func(t *testing.T) {
|
|
assert.True(t, ImageExists("./helper_test.go"))
|
|
})
|
|
}
|
|
|
|
func TestCheckAllowedType(t *testing.T) {
|
|
t.Run("not allowed type", func(t *testing.T) {
|
|
assert.False(t, CheckAllowedType("./helper_test.go"))
|
|
})
|
|
|
|
t.Run("allowed type", func(t *testing.T) {
|
|
assert.True(t, CheckAllowedType("test.jpg"))
|
|
})
|
|
}
|