mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-31 22:41:53 +02:00
@@ -14,6 +14,7 @@
|
||||
package page
|
||||
|
||||
import (
|
||||
"github.com/gohugoio/hugo/common/hugo"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
@@ -22,8 +23,13 @@ import (
|
||||
|
||||
func TestPageMatcher(t *testing.T) {
|
||||
c := qt.New(t)
|
||||
developmentTestSite := testSite{h: hugo.NewInfo("development", nil)}
|
||||
productionTestSite := testSite{h: hugo.NewInfo("production", nil)}
|
||||
|
||||
p1, p2, p3 := &testPage{path: "/p1", kind: "section", lang: "en"}, &testPage{path: "p2", kind: "page", lang: "no"}, &testPage{path: "p3", kind: "page", lang: "en"}
|
||||
p1, p2, p3 :=
|
||||
&testPage{path: "/p1", kind: "section", lang: "en", site: developmentTestSite},
|
||||
&testPage{path: "p2", kind: "page", lang: "no", site: productionTestSite},
|
||||
&testPage{path: "p3", kind: "page", lang: "en"}
|
||||
|
||||
c.Run("Matches", func(c *qt.C) {
|
||||
m := PageMatcher{Kind: "section"}
|
||||
@@ -50,6 +56,16 @@ func TestPageMatcher(t *testing.T) {
|
||||
c.Assert(m.Matches(p1), qt.Equals, true)
|
||||
c.Assert(m.Matches(p2), qt.Equals, false)
|
||||
c.Assert(m.Matches(p3), qt.Equals, true)
|
||||
|
||||
m = PageMatcher{Environment: "development"}
|
||||
c.Assert(m.Matches(p1), qt.Equals, true)
|
||||
c.Assert(m.Matches(p2), qt.Equals, false)
|
||||
c.Assert(m.Matches(p3), qt.Equals, false)
|
||||
|
||||
m = PageMatcher{Environment: "production"}
|
||||
c.Assert(m.Matches(p1), qt.Equals, false)
|
||||
c.Assert(m.Matches(p2), qt.Equals, true)
|
||||
c.Assert(m.Matches(p3), qt.Equals, false)
|
||||
})
|
||||
|
||||
c.Run("Decode", func(c *qt.C) {
|
||||
|
Reference in New Issue
Block a user