mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-31 22:41:53 +02:00
@@ -93,6 +93,9 @@ func TestNewContentFromDir(t *testing.T) {
|
||||
archetypeDir := filepath.Join("archetypes", "my-bundle")
|
||||
assert.NoError(fs.Source.Mkdir(archetypeDir, 0755))
|
||||
|
||||
archetypeThemeDir := filepath.Join("themes", "mytheme", "archetypes", "my-theme-bundle")
|
||||
assert.NoError(fs.Source.Mkdir(archetypeThemeDir, 0755))
|
||||
|
||||
contentFile := `
|
||||
File: %s
|
||||
Site Lang: {{ .Site.Language.Lang }}
|
||||
@@ -107,6 +110,9 @@ i18n: {{ T "hugo" }}
|
||||
assert.NoError(afero.WriteFile(fs.Source, filepath.Join(archetypeDir, "resources", "hugo1.json"), []byte(`hugo1: {{ printf "no template handling in here" }}`), 0755))
|
||||
assert.NoError(afero.WriteFile(fs.Source, filepath.Join(archetypeDir, "resources", "hugo2.xml"), []byte(`hugo2: {{ printf "no template handling in here" }}`), 0755))
|
||||
|
||||
assert.NoError(afero.WriteFile(fs.Source, filepath.Join(archetypeThemeDir, "index.md"), []byte(fmt.Sprintf(contentFile, "index.md")), 0755))
|
||||
assert.NoError(afero.WriteFile(fs.Source, filepath.Join(archetypeThemeDir, "resources", "hugo1.json"), []byte(`hugo1: {{ printf "no template handling in here" }}`), 0755))
|
||||
|
||||
h, err := hugolib.NewHugoSites(deps.DepsCfg{Cfg: cfg, Fs: fs})
|
||||
assert.NoError(err)
|
||||
assert.Equal(2, len(h.Sites))
|
||||
@@ -123,6 +129,10 @@ i18n: {{ T "hugo" }}
|
||||
|
||||
assertContains(assert, readFileFromFs(t, fs.Source, filepath.Join("content", "post/my-post/pages/bio.md")), `File: bio.md`, `Site Lang: en`, `Name: My Post`)
|
||||
|
||||
assert.NoError(create.NewContent(h, "my-theme-bundle", "post/my-theme-post"))
|
||||
assertContains(assert, readFileFromFs(t, fs.Source, filepath.Join("content", "post/my-theme-post/index.md")), `File: index.md`, `Site Lang: en`, `Name: My Theme Post`, `i18n: Hugo Rocks!`)
|
||||
assertContains(assert, readFileFromFs(t, fs.Source, filepath.Join("content", "post/my-theme-post/resources/hugo1.json")), `hugo1: {{ printf "no template handling in here" }}`)
|
||||
|
||||
}
|
||||
|
||||
func initFs(fs *hugofs.Fs) error {
|
||||
@@ -231,6 +241,8 @@ func readFileFromFs(t *testing.T, fs afero.Fs, filename string) string {
|
||||
func newTestCfg(assert *require.Assertions) (*viper.Viper, *hugofs.Fs) {
|
||||
|
||||
cfg := `
|
||||
|
||||
theme = "mytheme"
|
||||
|
||||
[languages]
|
||||
[languages.en]
|
||||
|
Reference in New Issue
Block a user