Verify png image is valid

This commit is contained in:
Melon 2023-06-05 17:26:56 +01:00
parent c64d89eb5c
commit b70c63dbbb
Signed by: melon
GPG Key ID: 6C9D970C50D26A25
2 changed files with 14 additions and 0 deletions

View File

@ -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)
}

View File

@ -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)
}