hugo

Fork of github.com/gohugoio/hugo with reverse pagination support

git clone git://git.shimmy1996.com/hugo.git

config_test.go (1653B)

    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 	qt "github.com/frankban/quicktest"
   20 	"github.com/gohugoio/hugo/config"
   21 )
   22 
   23 func TestConfig(t *testing.T) {
   24 	c := qt.New(t)
   25 	v := config.NewWithTestDefaults()
   26 
   27 	v.Set("minify", map[string]any{
   28 		"disablexml": true,
   29 		"tdewolff": map[string]any{
   30 			"html": map[string]any{
   31 				"keepwhitespace": false,
   32 			},
   33 		},
   34 	})
   35 
   36 	conf, err := decodeConfig(v)
   37 
   38 	c.Assert(err, qt.IsNil)
   39 
   40 	c.Assert(conf.MinifyOutput, qt.Equals, false)
   41 
   42 	// explicitly set value
   43 	c.Assert(conf.Tdewolff.HTML.KeepWhitespace, qt.Equals, false)
   44 	// default value
   45 	c.Assert(conf.Tdewolff.HTML.KeepEndTags, qt.Equals, true)
   46 	c.Assert(conf.Tdewolff.CSS.KeepCSS2, qt.Equals, true)
   47 
   48 	// `enable` flags
   49 	c.Assert(conf.DisableHTML, qt.Equals, false)
   50 	c.Assert(conf.DisableXML, qt.Equals, true)
   51 }
   52 
   53 func TestConfigLegacy(t *testing.T) {
   54 	c := qt.New(t)
   55 	v := config.NewWithTestDefaults()
   56 
   57 	// This was a bool < Hugo v0.58.
   58 	v.Set("minify", true)
   59 
   60 	conf, err := decodeConfig(v)
   61 	c.Assert(err, qt.IsNil)
   62 	c.Assert(conf.MinifyOutput, qt.Equals, true)
   63 }