Debian Codegraph @

hugolib/gitinfo_github_test.go

raw ◀ ▶
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 hugolib
15
16 import (
17 "testing"
•18 "os"
19 )
20
21 func TestGitInfoFromGitModuleWithVersionQuery(t *testing.T) {
•22 t.Skip("This tests needs internet access")
23 t.Parallel()
24
25 files := `
26 -- hugo.toml --
27 baseURL = "https://example.com/"
28 enableGitInfo = true
29
30 [module]
31 [[module.imports]]
32 path = "github.com/bep/hugo-testing-git-versions"
33 version = "v3.0.0"
34 [[module.imports.mounts]]
35 source = "content"
36 target = "content"
37 [[module.imports]]
38 path = "github.com/bep/hugo-testing-git-versions"
39 version = "v3.0.1"
40 [[module.imports.mounts]]
41 source = "content"
42 target = "content/301"
43 -- layouts/page.html --
44 Title: {{ .Title }}|
45 GitInfo: {{ with .GitInfo }}Hash: {{ .Hash }}|Subject: {{ .Subject }}|AuthorName: {{ .AuthorName }}{{ end }}|
46 Content: {{ .Content }}|
47 -- layouts/_default/list.html --
48 List: {{ .Title }}
49 `
50
51 b := Test(t, files, TestOptOsFs())
52
53 b.AssertFileContent("public/docs/functions/mean/index.html",
54 "Hash: 9769b63d4a4abdd406e333be5fb8b5d48737d3a9|",
55 "AuthorName: Bjørn Erik Pedersen|",
56 )
57
58 b.AssertFileContent("public/docs/functions/standard-deviation/index.html",
59 "Hash: 2d92492a7f1ec4968529ee12cf62ed652eb45950|Subject: v3.0.0 edits|",
60 "AuthorName: Bjørn Erik Pedersen|",
61 )
62
63 b.AssertFileContent("public/301/docs/functions/standard-deviation/index.html",
64 "Hash: 3e0f3930f1ec9a29a7442da5f1bfc0b7e58f167a|Subject: v3.0.1 edit|",
65 "AuthorName: Bjørn Erik Pedersen|",
66 )
67 }
68
69 func TestGitInfoFromGitModuleWithGoMod(t *testing.T) {
•70 t.Skip("This tests needs internet access")
71 t.Parallel()
72
73 files := `
74 -- hugo.toml --
75 baseURL = "https://example.com/"
76 enableGitInfo = true
77
78 [module]
79 [[module.imports]]
80 path = "github.com/bep/hugo-mod-testing-content"
81 [[module.imports.mounts]]
82 source = "content"
83 target = "content"
84 -- layouts/page.html --
85 Title: {{ .Title }}|
86 GitInfo: {{ with .GitInfo }}Hash: {{ .Hash }}|Subject: {{ .Subject }}|AuthorName: {{ .AuthorName }}{{ end }}|
87 Content: {{ .Content }}|
88 -- layouts/_default/list.html --
89 List: {{ .Title }}
90 -- go.mod --
91 module hugotest
92 `
93
94 b := Test(t, files, TestOptOsFs())
95
96 b.AssertFileContent("public/docs/functions/kurtosis/index.html",
97 "Hash: 668663b54d0937df05185d144765d13c3ffda489|",
98 "AuthorName: Bjørn Erik Pedersen|",
99 )
100 }
101
102 // See issue 14942.
103 func TestGitInfoFromGitModuleWithGoModInSubdir(t *testing.T) {
•104 if os.Getenv("AUTOPKGTEST_TMP") == "" {
105 t.Skip("Skip test as network is inaccessible during Debian package build")
106 }
107 t.Parallel()
108
109 files := `
110 -- hugo.toml --
111 baseURL = "https://example.com/"
112 enableGitInfo = true
113
114 [module]
115 [[module.imports]]
116 path = "github.com/bep/hugo-mod-misc/dummy-content"
117 version = "v0.3.0"
118 [[module.imports.mounts]]
119 source = "content"
120 target = "content"
121 -- layouts/page.html --
122 Title: {{ .Title }}|
123 GitInfo: {{ with .GitInfo }}Hash: {{ .Hash }}|Subject: {{ .Subject }}|AuthorName: {{ .AuthorName }}{{ end }}|
124 -- layouts/_default/list.html --
125 List: {{ .Title }}
126 -- go.mod --
127 module hugotest
128 `
129
130 b := Test(t, files, TestOptOsFs())
131
132 b.AssertFileContent("public/blog/music/satin-doll/index.html",
133 "Hash: 522ee6c486ff24b2e3d45e9b90061564e9427030|",
134 "AuthorName: Bjørn Erik Pedersen|",
135 )
136 }