Debian Codegraph @

modules/modules_integration_test.go

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
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 "github.com/gohugoio/hugo/hugolib"
20 )
21
22 func TestModuleImportWithVersion(t *testing.T) {
23 t.Parallel()
24
25 files := `
26 -- hugo.toml --
27 baseURL = "https://example.org"
28 [[module.imports]]
29 path = "github.com/bep/hugo-mod-misc/dummy-content"
30 version = "v0.2.0"
31 [[module.imports]]
32 path = "github.com/bep/hugo-mod-misc/dummy-content"
33 version = "v0.1.0"
34 [[module.imports.mounts]]
35 source = "content"
36 target = "content/v1"
37 -- layouts/all.html --
38 Title: {{ .Title }}|Summary: {{ .Summary }}|
39 Deps: {{ range hugo.Deps}}{{ printf "%s@%s" .Path .Version }}|{{ end }}$
40
41 `
42
43 b := hugolib.Test(t, files, hugolib.TestOptWithOSFs())
44
45 b.AssertFileContent("public/index.html", "Deps: project@|github.com/bep/hugo-mod-misc/[email protected]|github.com/bep/hugo-mod-misc/[email protected]|$")
46
47 b.AssertFileContent("public/blog/music/autumn-leaves/index.html", "Autumn Leaves is a popular jazz standard") // v0.2.0
48 b.AssertFileContent("public/v1/blog/music/autumn-leaves/index.html", "Lorem markdownum, placidi peremptis") // v0.1.0
49 }