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