| 1 |
// Copyright 2025 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 modules_test |
| 15 |
|
| 16 |
import ( |
| 17 |
"testing" |
| 18 |
|
| 19 |
qt "github.com/frankban/quicktest" |
| 20 |
"github.com/gohugoio/hugo/hugolib" |
| 21 |
) |
| 22 |
|
| 23 |
func TestMountsProjectDefaults(t *testing.T) { |
| 24 |
t.Parallel() |
| 25 |
|
| 26 |
files := ` |
| 27 |
-- hugo.toml -- |
| 28 |
[languages] |
| 29 |
[languages.en] |
| 30 |
weight = 1 |
| 31 |
[languages.sv] |
| 32 |
weight = 2 |
| 33 |
|
| 34 |
[module] |
| 35 |
[[module.mounts]] |
| 36 |
source = 'content' |
| 37 |
target = 'content' |
| 38 |
lang = 'en' |
| 39 |
-- content/p1.md -- |
| 40 |
|
| 41 |
` |
| 42 |
b := hugolib.Test(t, files) |
| 43 |
|
| 44 |
b.Assert(len(b.H.Configs.Modules), qt.Equals, 1) |
| 45 |
projectMod := b.H.Configs.Modules[0] |
| 46 |
b.Assert(projectMod.Path(), qt.Equals, "project") |
| 47 |
mounts := projectMod.Mounts() |
| 48 |
b.Assert(len(mounts), qt.Equals, 7) |
| 49 |
contentMount := mounts[0] |
| 50 |
b.Assert(contentMount.Source, qt.Equals, "content") |
| 51 |
b.Assert(contentMount.Sites.Matrix.Languages, qt.DeepEquals, []string{"en"}) |
| 52 |
} |
| 53 |
|
| 54 |
func TestMountsLangIsDeprecated(t *testing.T) { |
| 55 |
t.Parallel() |
| 56 |
files := ` |
| 57 |
-- hugo.toml -- |
| 58 |
[module] |
| 59 |
[[module.mounts]] |
| 60 |
source = 'content' |
| 61 |
target = 'content' |
| 62 |
lang = 'en' |
| 63 |
-- layouts/all.html -- |
| 64 |
All. |
| 65 |
` |
| 66 |
|
| 67 |
b := hugolib.Test(t, files, hugolib.TestOptInfo()) |
| 68 |
b.AssertLogContains("deprecated") |
| 69 |
} |