hugolib: Add a symdiff test
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 24 Jul 2019 08:05:09 +0000 (10:05 +0200)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 24 Jul 2019 08:05:09 +0000 (10:05 +0200)
hugolib/collections_test.go

index 41681bc7394db1d3d306ea0a8485d70101ece0f7..06bac80a3aeb6e3f735cc59d4ab74d7a221ad591 100644 (file)
@@ -141,6 +141,13 @@ tags_weight: %d
 {{ printf "uniqPages: %T %d" $uniqPages (len $uniqPages) }}
 {{ printf "inTrue: %t" $inTrue }}
 {{ printf "inFalse: %t" $inFalse  }}
+`)
+
+       b.WithTemplatesAdded("_default/single.html", `
+{{ $related := .Site.RegularPages.Related . }}
+{{ $symdiff := $related | symdiff .Site.RegularPages }}
+Related: {{ range $related }}{{ .RelPermalink }}|{{ end }}
+Symdiff: {{ range $symdiff }}{{ .RelPermalink }}|{{ end }}
 `)
        b.CreateSites().Build(BuildCfg{})
 
@@ -152,6 +159,8 @@ tags_weight: %d
                "inTrue: true",
                "inFalse: false",
        )
+
+       b.AssertFileContent("public/page1/index.html", `Related: /page2/|/page3/|`, `Symdiff: /page1/|`)
 }
 
 func TestAppendFunc(t *testing.T) {