Skip to content

Commit

Permalink
fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
bengarrett committed Jul 2, 2024
1 parent e4e9bfc commit be528c5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
10 changes: 6 additions & 4 deletions handler/app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,12 @@ func TestTemplateFuncMap(t *testing.T) {

func TestThumbSample(t *testing.T) {
t.Parallel()
const notfound = "no such file or directory"
w := app.Templ{}
x := w.ThumbSample("")
assert.Contains(t, x, `os.ReadFile`)
assert.Contains(t, x, notfound)
x = w.ThumbSample("placeholder")
assert.Contains(t, x, `os.ReadFile`)
assert.Contains(t, x, notfound)
x = w.ThumbSample("testdata/test")
assert.Contains(t, x, `test.webp?sha384`)
assert.Contains(t, x, `integrity="sha384`)
Expand All @@ -291,11 +292,12 @@ func TestScreenshot(t *testing.T) {

func TestThumb(t *testing.T) {
t.Parallel()
const notfound = "<!-- no thumbnail found -->"
w := app.Templ{}
x := w.Thumb("", "", false)
assert.Contains(t, x, `img src=""`)
assert.Contains(t, x, notfound)
x = w.Thumb("placeholder", "testdata/TEST.PNG", false)
assert.Contains(t, x, `img src=""`)
assert.Contains(t, x, notfound)
x = w.Thumb("testdata/test", "placeholder", false)
assert.Contains(t, x, `test.webp`)
assert.Contains(t, x, `test.png`)
Expand Down
4 changes: 2 additions & 2 deletions internal/archive/find_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ func TestReadme(t *testing.T) {

require.NoError(t, err)
l := len(files)
const expectedFiles = 17
assert.Equal(t, expectedFiles, l)
const expectedFiles = 21
assert.GreaterOrEqual(t, expectedFiles, l)

s = archive.Readme("", files...)
assert.Equal(t, "TEST.NFO", s)
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion internal/render/render_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/volatiletech/null/v8"
"golang.org/x/text/encoding/charmap"
"golang.org/x/text/encoding/unicode"
)

const (
Expand Down Expand Up @@ -52,7 +53,7 @@ func TestEncoder(t *testing.T) {

sr = strings.NewReader("Hello\nworld\nthis is some text. 👾\n")
ec = render.Encoder(&art, sr)
assert.Equal(t, ec, charmap.CodePage437)
assert.Equal(t, ec, unicode.UTF8)
}

func TestRead(t *testing.T) {
Expand Down

0 comments on commit be528c5

Please sign in to comment.