github.com/anakojm/hugo-katex@v0.0.0-20231023141351-42d6f5de9c0b/config/allconfig/integration_test.go (about)

     1  package allconfig_test
     2  
     3  import (
     4  	"path/filepath"
     5  	"testing"
     6  
     7  	qt "github.com/frankban/quicktest"
     8  	"github.com/gohugoio/hugo/config/allconfig"
     9  	"github.com/gohugoio/hugo/hugolib"
    10  )
    11  
    12  func TestDirsMount(t *testing.T) {
    13  
    14  	files := `
    15  -- hugo.toml --
    16  baseURL = "https://example.com"
    17  disableKinds = ["taxonomy", "term"]
    18  [languages]
    19  [languages.en]
    20  weight = 1
    21  [languages.sv]
    22  weight = 2
    23  [[module.mounts]]
    24  source = 'content/en'
    25  target = 'content'
    26  lang = 'en'
    27  [[module.mounts]]
    28  source = 'content/sv'
    29  target = 'content'
    30  lang = 'sv'
    31  -- content/en/p1.md --
    32  ---
    33  title: "p1"
    34  ---
    35  -- content/sv/p1.md --
    36  ---
    37  title: "p1"
    38  ---
    39  -- layouts/_default/single.html --
    40  Title: {{ .Title }}
    41  	`
    42  
    43  	b := hugolib.NewIntegrationTestBuilder(
    44  		hugolib.IntegrationTestConfig{T: t, TxtarString: files},
    45  	).Build()
    46  
    47  	//b.AssertFileContent("public/p1/index.html", "Title: p1")
    48  
    49  	sites := b.H.Sites
    50  	b.Assert(len(sites), qt.Equals, 2)
    51  
    52  	configs := b.H.Configs
    53  	mods := configs.Modules
    54  	b.Assert(len(mods), qt.Equals, 1)
    55  	mod := mods[0]
    56  	b.Assert(mod.Mounts(), qt.HasLen, 8)
    57  
    58  	enConcp := sites[0].Conf
    59  	enConf := enConcp.GetConfig().(*allconfig.Config)
    60  
    61  	b.Assert(enConcp.BaseURL().String(), qt.Equals, "https://example.com")
    62  	modConf := enConf.Module
    63  	b.Assert(modConf.Mounts, qt.HasLen, 8)
    64  	b.Assert(modConf.Mounts[0].Source, qt.Equals, filepath.FromSlash("content/en"))
    65  	b.Assert(modConf.Mounts[0].Target, qt.Equals, "content")
    66  	b.Assert(modConf.Mounts[0].Lang, qt.Equals, "en")
    67  	b.Assert(modConf.Mounts[1].Source, qt.Equals, filepath.FromSlash("content/sv"))
    68  	b.Assert(modConf.Mounts[1].Target, qt.Equals, "content")
    69  	b.Assert(modConf.Mounts[1].Lang, qt.Equals, "sv")
    70  
    71  }
    72  
    73  func TestConfigAliases(t *testing.T) {
    74  
    75  	files := `
    76  -- hugo.toml --
    77  baseURL = "https://example.com"
    78  logI18nWarnings = true
    79  logPathWarnings = true
    80  `
    81  	b := hugolib.NewIntegrationTestBuilder(
    82  		hugolib.IntegrationTestConfig{T: t, TxtarString: files},
    83  	).Build()
    84  
    85  	conf := b.H.Configs.Base
    86  
    87  	b.Assert(conf.PrintI18nWarnings, qt.Equals, true)
    88  	b.Assert(conf.PrintPathWarnings, qt.Equals, true)
    89  }