mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-15 20:44:01 +02:00
@@ -18,6 +18,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/gohugoio/hugo/common/herrors"
|
||||
"github.com/gohugoio/hugo/common/loggers"
|
||||
"github.com/gohugoio/hugo/common/types"
|
||||
|
||||
qt "github.com/frankban/quicktest"
|
||||
@@ -91,7 +92,7 @@ status = 301
|
||||
|
||||
s, err := DecodeServer(cfg)
|
||||
c.Assert(err, qt.IsNil)
|
||||
c.Assert(s.CompileConfig(), qt.IsNil)
|
||||
c.Assert(s.CompileConfig(loggers.NewErrorLogger()), qt.IsNil)
|
||||
|
||||
c.Assert(s.MatchHeaders("/foo.jpg"), qt.DeepEquals, []types.KeyValueStr{
|
||||
{Key: "X-Content-Type-Options", Value: "nosniff"},
|
||||
@@ -139,3 +140,27 @@ status = 301`,
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildConfigCacheBusters(t *testing.T) {
|
||||
c := qt.New(t)
|
||||
cfg := New()
|
||||
conf := DecodeBuildConfig(cfg)
|
||||
l := loggers.NewInfoLogger()
|
||||
c.Assert(conf.CompileConfig(l), qt.IsNil)
|
||||
|
||||
m, err := conf.MatchCacheBuster(l, "assets/foo/main.js")
|
||||
c.Assert(err, qt.IsNil)
|
||||
c.Assert(m, qt.IsNotNil)
|
||||
c.Assert(m("scripts"), qt.IsTrue)
|
||||
c.Assert(m("asdf"), qt.IsFalse)
|
||||
|
||||
m, _ = conf.MatchCacheBuster(l, "tailwind.config.js")
|
||||
c.Assert(m("css"), qt.IsTrue)
|
||||
c.Assert(m("js"), qt.IsFalse)
|
||||
|
||||
m, err = conf.MatchCacheBuster(l, "assets/foo.json")
|
||||
c.Assert(err, qt.IsNil)
|
||||
c.Assert(m, qt.IsNotNil)
|
||||
c.Assert(m("json"), qt.IsTrue)
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user