mirror of
https://github.com/1f349/violet.git
synced 2024-11-24 04:11:32 +00:00
Verify png image is valid
This commit is contained in:
parent
c64d89eb5c
commit
b70c63dbbb
@ -1,7 +1,9 @@
|
||||
package favicons
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"image/png"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@ -18,4 +20,9 @@ func TestFaviconList_PreProcess(t *testing.T) {
|
||||
assert.Equal(t, "74cdc17d0502a690941799c327d9ca1ed042e76c784def43a42937f2eed270b4", icons.Svg.Hash)
|
||||
assert.NotEqual(t, "", icons.Png.Hash)
|
||||
assert.NotEqual(t, "", icons.Ico.Hash)
|
||||
|
||||
// verify png bytes are a valid png image
|
||||
pngRaw := bytes.NewBuffer(icons.Png.Raw)
|
||||
_, err := png.Decode(pngRaw)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
@ -1,10 +1,12 @@
|
||||
package favicons
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"database/sql"
|
||||
_ "embed"
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"image/png"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@ -36,4 +38,9 @@ func TestFaviconsNew(t *testing.T) {
|
||||
assert.Equal(t, "74cdc17d0502a690941799c327d9ca1ed042e76c784def43a42937f2eed270b4", icons.Svg.Hash)
|
||||
assert.NotEqual(t, "", icons.Png.Hash)
|
||||
assert.NotEqual(t, "", icons.Ico.Hash)
|
||||
|
||||
// verify png bytes are a valid png image
|
||||
pngRaw := bytes.NewBuffer(icons.Png.Raw)
|
||||
_, err = png.Decode(pngRaw)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user