mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-28 06:30:33 +03:00
resources/images: Add some golden tests for images.QR
This commit is contained in:
parent
c5a63a3b4f
commit
892b49110e
3 changed files with 36 additions and 0 deletions
|
@ -229,6 +229,42 @@ Home.
|
||||||
runGolden(t, name, files)
|
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 {
|
func runGolden(t testing.TB, name, files string) *hugolib.IntegrationTestBuilder {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
||||||
|
|
BIN
resources/images/testdata/images_golden/funcs/qr-default.png
vendored
Normal file
BIN
resources/images/testdata/images_golden/funcs/qr-default.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 663 B |
BIN
resources/images/testdata/images_golden/funcs/qr-level-high_scale-6.png
vendored
Normal file
BIN
resources/images/testdata/images_golden/funcs/qr-level-high_scale-6.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
Loading…
Add table
Add a link
Reference in a new issue