Debian Codegraph @

hugolib/minify_publisher_test.go

raw
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 )
19
20 func TestMinifyPublisher(t *testing.T) {
21 t.Parallel()
22
23 files := `
24 -- hugo.toml --
25 baseURL = "https://example.org/"
26 [minify]
27 minifyOutput = true
28 -- layouts/home.html --
29 <!DOCTYPE html>
30 <html lang="en">
31 <head>
32 <meta charset="utf-8">
33 <title>HTML5 boilerplate – all you really need…</title>
34 <link rel="stylesheet" href="css/style.css">
35 <!--[if IE]>
36 <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
37 <![endif]-->
38 </head>
39
40 <body id="home">
41
42 <h1>{{ .Title }}</h1>
43 <p>{{ .Permalink }}</p>
44
45 </body>
46 </html>
47 `
48 b := Test(t, files)
49
50 // Check minification
51 // HTML
52 b.AssertFileContent("public/index.html", "<!doctype html>")
53
54 // RSS
55 b.AssertFileContent("public/index.xml", "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?><rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\"><channel><title/><link>https://example.org/</link>")
56
57 // Sitemap
58 b.AssertFileContent("public/sitemap.xml", "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?><urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\" xmlns:xhtml=\"http://www.w3.org/1999/xhtml\"><url><loc>h")
59 }