github.com/gohugoio/hugo@v0.88.1/minifiers/config_test.go (about) 1 // Copyright 2019 The Hugo Authors. All rights reserved. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // http://www.apache.org/licenses/LICENSE-2.0 7 // 8 // Unless required by applicable law or agreed to in writing, software 9 // distributed under the License is distributed on an "AS IS" BASIS, 10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // See the License for the specific language governing permissions and 12 // limitations under the License. 13 14 package minifiers 15 16 import ( 17 "testing" 18 19 "github.com/gohugoio/hugo/config" 20 21 qt "github.com/frankban/quicktest" 22 ) 23 24 func TestConfig(t *testing.T) { 25 c := qt.New(t) 26 v := config.New() 27 28 v.Set("minify", map[string]interface{}{ 29 "disablexml": true, 30 "tdewolff": map[string]interface{}{ 31 "html": map[string]interface{}{ 32 "keepwhitespace": false, 33 }, 34 }, 35 }) 36 37 conf, err := decodeConfig(v) 38 39 c.Assert(err, qt.IsNil) 40 41 c.Assert(conf.MinifyOutput, qt.Equals, false) 42 43 // explicitly set value 44 c.Assert(conf.Tdewolff.HTML.KeepWhitespace, qt.Equals, false) 45 // default value 46 c.Assert(conf.Tdewolff.HTML.KeepEndTags, qt.Equals, true) 47 c.Assert(conf.Tdewolff.CSS.KeepCSS2, qt.Equals, true) 48 49 // `enable` flags 50 c.Assert(conf.DisableHTML, qt.Equals, false) 51 c.Assert(conf.DisableXML, qt.Equals, true) 52 } 53 54 func TestConfigLegacy(t *testing.T) { 55 c := qt.New(t) 56 v := config.New() 57 58 // This was a bool < Hugo v0.58. 59 v.Set("minify", true) 60 61 conf, err := decodeConfig(v) 62 c.Assert(err, qt.IsNil) 63 c.Assert(conf.MinifyOutput, qt.Equals, true) 64 }