Skip to content

Commit

Permalink
resources/images: Add some golden tests for images.QR
Browse files Browse the repository at this point in the history
  • Loading branch information
bep committed Jan 9, 2025
1 parent c5a63a3 commit 892b491
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions resources/images/images_golden_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,42 @@ Home.
runGolden(t, name, files)
}

func TestGoldenFuncs(t *testing.T) {
t.Parallel()

if skipGolden {
t.Skip("Skip golden test on this architecture")
}

// Will be used to generate golden files.
name := "funcs"

files := `
-- hugo.toml --
-- assets/sunset.jpg --
sourcefilename: ../testdata/sunset.jpg
-- layouts/index.html --
Home.
{{ template "copy" (dict "name" "qr-default.png" "img" (images.QR "https://gohugo.io")) }}
{{ template "copy" (dict "name" "qr-level-high_scale-6.png" "img" (images.QR "https://gohugo.io" (dict "level" "high" "scale" 6))) }}
{{ define "copy"}}
{{ if lt (len (path.Ext .name)) 4 }}
{{ errorf "No extension in %q" .name }}
{{ end }}
{{ $img := .img }}
{{ $name := printf "images/%s" .name }}
{{ with $img | resources.Copy $name }}
{{ .Publish }}
{{ end }}
{{ end }}
`

runGolden(t, name, files)
}

func runGolden(t testing.TB, name, files string) *hugolib.IntegrationTestBuilder {
t.Helper()

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 892b491

Please sign in to comment.