config_test.go (1548B)
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 markup_config 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 27 c.Run("Decode", func(c *qt.C) { 28 c.Parallel() 29 v := config.New() 30 31 v.Set("markup", map[string]any{ 32 "goldmark": map[string]any{ 33 "renderer": map[string]any{ 34 "unsafe": true, 35 }, 36 }, 37 "asciidocext": map[string]any{ 38 "workingFolderCurrent": true, 39 "safeMode": "save", 40 "extensions": []string{"asciidoctor-html5s"}, 41 }, 42 }) 43 44 conf, err := Decode(v) 45 46 c.Assert(err, qt.IsNil) 47 c.Assert(conf.Goldmark.Renderer.Unsafe, qt.Equals, true) 48 c.Assert(conf.Goldmark.Parser.Attribute.Title, qt.Equals, true) 49 c.Assert(conf.Goldmark.Parser.Attribute.Block, qt.Equals, false) 50 51 c.Assert(conf.AsciidocExt.WorkingFolderCurrent, qt.Equals, true) 52 c.Assert(conf.AsciidocExt.Extensions[0], qt.Equals, "asciidoctor-html5s") 53 }) 54 55 }