From 892b49110e52e9c04bee414ddc2f8deead419103 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Wed, 8 Jan 2025 22:03:41 +0100 Subject: [PATCH] resources/images: Add some golden tests for images.QR --- .../images/images_golden_integration_test.go | 36 ++++++++++++++++++ .../images_golden/funcs/qr-default.png | Bin 0 -> 663 bytes .../funcs/qr-level-high_scale-6.png | Bin 0 -> 1112 bytes 3 files changed, 36 insertions(+) create mode 100644 resources/images/testdata/images_golden/funcs/qr-default.png create mode 100644 resources/images/testdata/images_golden/funcs/qr-level-high_scale-6.png diff --git a/resources/images/images_golden_integration_test.go b/resources/images/images_golden_integration_test.go index dd2a6e06026..20f3d23f99e 100644 --- a/resources/images/images_golden_integration_test.go +++ b/resources/images/images_golden_integration_test.go @@ -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() diff --git a/resources/images/testdata/images_golden/funcs/qr-default.png b/resources/images/testdata/images_golden/funcs/qr-default.png new file mode 100644 index 0000000000000000000000000000000000000000..6c7ab919ec95449b80db2823ecf06c048cc09072 GIT binary patch literal 663 zcmY*X!Aj#$6paSrAk`qVY28Fb5QecWbSHyBY1MAjab_{gl%jPrIHLg-w4ovqR|@V8 z%m>WYl_F*}t9-&(80f}Dm~LJmpS`S?)O6D^5jlY zhV#|(;@88Wy0{!)u3S~J2^yC51hiGtR89(>2ukrVw=&DD+U0=r{-RE{1h zRDXnxWnyC?>~{sKr!@jCf{-FDg+G$O5D~~H>5ir|fMZ!A2)&lqHgQhWv@Mf%HC<#F z%=NsIs~~L44qScE0p>~GEgf?dJqM*(py>$)0HoOrA5|s|nQ-JJd#dD!2*(xz zcog}+%vsC%Kn_~+vov*3)3m1cDwR&AppISqaQbmr`TOfutkj-e`Nvf&Yvtcd*69n8 CXov9t literal 0 HcmV?d00001 diff --git a/resources/images/testdata/images_golden/funcs/qr-level-high_scale-6.png b/resources/images/testdata/images_golden/funcs/qr-level-high_scale-6.png new file mode 100644 index 0000000000000000000000000000000000000000..17e00f1a1140b47422672a252506fdca97511558 GIT binary patch literal 1112 zcmZWp&ui0g6i*E#FgkP1h7b=0Pp-w`WjMm5L)$~q+Jnc8soh1UH863=cd@V{h?99~ z58M0;r2l}BQalKSdF)BHOA(x`P$(&jd467!*5MxM_xsIz@B4myJ}-THuW)C2YIaJJ zr0Lw?FPW$wj>y}CBH zy8bj>-g*5+lH}7|cB%9-vFh!p@AB{Smy5Y=BAU-Yx>$X3`!zBLssic3qAf%YI8yZw zX+xpwx~FAC6AE*HMcqrau{F$0q{N+J$2e)2h}WHmMSRcQ@QDsavOG{Xds-5@a^Uu< zx+qr{FNSD~Er(nqkm+IwTs2ORxL<1pq$)ja7zV@g>Ek001{s2&oF}S+JIlZxSAkO~ zZR^l=T|a6e)-7H8*5{*fGNa?sgYZp~5!R;$4Cc?&On|-SI1W;g=#d)q4eN*w{nq{n zmTF=57#sR0(JWgGk~AQ>gZ$4t-RmZYs)ljAL6IQ3Q%%@A5bh zKp2q&GfMW@3<6m{$pSO#fM5VI0CbMMcmP9hri2KTa48%!aejz-6uJnxu>k4Y