Add minify config

Fixes #6750
Updates #6892
This commit is contained in:
SatowTakeshi
2020-02-29 18:44:05 +09:00
committed by Bjørn Erik Pedersen
parent 99958f90fe
commit 574c2959b8
12 changed files with 346 additions and 47 deletions

View File

@@ -27,7 +27,7 @@ func TestTransform(t *testing.T) {
spec, err := htesting.NewTestResourceSpec()
c.Assert(err, qt.IsNil)
client := New(spec)
client, _ := New(spec)
r, err := htesting.NewResourceTransformerForSpec(spec, "hugo.html", "<h1> Hugo Rocks! </h1>")
c.Assert(err, qt.IsNil)
@@ -41,3 +41,23 @@ func TestTransform(t *testing.T) {
c.Assert(content, qt.Equals, "<h1>Hugo Rocks!</h1>")
}
func TestNoMinifier(t *testing.T) {
c := qt.New(t)
spec, _ := htesting.NewTestResourceSpec()
spec.Cfg.Set("minifiers.enableXML", false)
client, _ := New(spec)
original := "<title> Hugo Rocks! </title>"
r, err := htesting.NewResourceTransformerForSpec(spec, "hugo.xml", original)
c.Assert(err, qt.IsNil)
transformed, err := client.Minify(r)
c.Assert(err, qt.IsNil)
content, err := transformed.(resource.ContentProvider).Content()
// error should be ignored because general users cannot control codes under `theme`s
c.Assert(err, qt.IsNil)
c.Assert(content, qt.Equals, original)
}