mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-16 20:53:59 +02:00
@@ -15,14 +15,10 @@ package hugolib
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
jww "github.com/spf13/jwalterweatherman"
|
||||
|
||||
"fmt"
|
||||
"io"
|
||||
"math/rand"
|
||||
"os"
|
||||
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
@@ -30,6 +26,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
jww "github.com/spf13/jwalterweatherman"
|
||||
|
||||
"github.com/gohugoio/hugo/common/herrors"
|
||||
|
||||
"github.com/gohugoio/hugo/htesting"
|
||||
@@ -92,7 +90,6 @@ T1: {{ $r.Content }}
|
||||
b.Build(BuildCfg{})
|
||||
|
||||
b.AssertFileContent(filepath.Join(workDir, "public/index.html"), `T1: moo{color:#fff}`)
|
||||
|
||||
}
|
||||
|
||||
func TestSCSSWithRegularCSSImport(t *testing.T) {
|
||||
@@ -155,7 +152,6 @@ moo {
|
||||
/* foo */
|
||||
|
||||
`)
|
||||
|
||||
}
|
||||
|
||||
func TestSCSSWithThemeOverrides(t *testing.T) {
|
||||
@@ -241,7 +237,6 @@ T1: {{ $r.Content }}
|
||||
b.Build(BuildCfg{})
|
||||
|
||||
b.AssertFileContent(filepath.Join(workDir, "public/index.html"), `T1: moo{color:#ccc}boo{color:green}`)
|
||||
|
||||
}
|
||||
|
||||
// https://github.com/gohugoio/hugo/issues/6274
|
||||
@@ -289,7 +284,6 @@ T1: {{ $r.Content }}
|
||||
b.Build(BuildCfg{})
|
||||
|
||||
b.AssertFileContent(filepath.Join(workDir, "public/index.html"), `T1: foo{color:#ccc}`)
|
||||
|
||||
}
|
||||
|
||||
func TestResourceChainBasic(t *testing.T) {
|
||||
@@ -394,11 +388,9 @@ End.`)
|
||||
|
||||
b.AssertFileContent("public/page1/index.html", `HELLO: /hello.min.a2d1cb24f24b322a7dad520414c523e9.html`)
|
||||
b.AssertFileContent("public/page2/index.html", `HELLO: /hello.min.a2d1cb24f24b322a7dad520414c523e9.html`)
|
||||
|
||||
}
|
||||
|
||||
func BenchmarkResourceChainPostProcess(b *testing.B) {
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
b.StopTimer()
|
||||
s := newTestSitesBuilder(b)
|
||||
@@ -431,7 +423,6 @@ End.
|
||||
s.Build(BuildCfg{})
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestResourceChains(t *testing.T) {
|
||||
@@ -472,7 +463,6 @@ T6: {{ $bundle1.Permalink }}
|
||||
|
||||
c.Assert(b.CheckExists("public/styles/templ.min.css"), qt.Equals, false)
|
||||
b.AssertFileContent("public/styles/bundle1.css", `.home{color:blue}body{color:#333}`)
|
||||
|
||||
}},
|
||||
|
||||
{"minify", func() bool { return true }, func(b *sitesBuilder) {
|
||||
@@ -550,10 +540,8 @@ T3: Content: {{ $combinedJs.Content }}|{{ $combinedJs.RelPermalink }}
|
||||
Fingerprinted: {{ $fingerprinted.RelPermalink }}
|
||||
`)
|
||||
}, func(b *sitesBuilder) {
|
||||
|
||||
b.AssertFileContent("public/index.html", "Fingerprinted: /bundle/concat.b5d4045c3f466fa91fe2cc6abe79232a1a57cdf104f7a26e716e0a1e2789df78.txt")
|
||||
b.AssertFileContent("public/bundle/concat.b5d4045c3f466fa91fe2cc6abe79232a1a57cdf104f7a26e716e0a1e2789df78.txt", "ABC")
|
||||
|
||||
}},
|
||||
|
||||
{"fromstring", func() bool { return true }, func(b *sitesBuilder) {
|
||||
@@ -561,11 +549,9 @@ Fingerprinted: {{ $fingerprinted.RelPermalink }}
|
||||
{{ $r := "Hugo Rocks!" | resources.FromString "rocks/hugo.txt" }}
|
||||
{{ $r.Content }}|{{ $r.RelPermalink }}|{{ $r.Permalink }}|{{ $r.MediaType.Type }}
|
||||
`)
|
||||
|
||||
}, func(b *sitesBuilder) {
|
||||
b.AssertFileContent("public/index.html", `Hugo Rocks!|/rocks/hugo.txt|http://example.com/rocks/hugo.txt|text/plain`)
|
||||
b.AssertFileContent("public/rocks/hugo.txt", "Hugo Rocks!")
|
||||
|
||||
}},
|
||||
{"execute-as-template", func() bool {
|
||||
return true
|
||||
@@ -579,10 +565,8 @@ T1: {{ $var }}
|
||||
{{ $result := "{{ .Kind | upper }}" | resources.FromString "mytpl.txt" | resources.ExecuteAsTemplate "result.txt" . }}
|
||||
T2: {{ $result.Content }}|{{ $result.RelPermalink}}|{{$result.MediaType.Type }}
|
||||
`)
|
||||
|
||||
}, func(b *sitesBuilder) {
|
||||
b.AssertFileContent("public/index.html", `T2: HOME|/result.txt|text/plain`, `T1: Hugo Home`)
|
||||
|
||||
}},
|
||||
{"fingerprint", func() bool { return true }, func(b *sitesBuilder) {
|
||||
b.WithTemplates("home.html", `
|
||||
@@ -604,7 +588,6 @@ T4: {{ $r2.Data.Integrity }}|
|
||||
b.AssertFileContent("public/index.html", `T2: ab|/rocks/hugo.2d408a0717ec188158278a796c689044361dc6fdde28d6f04973b80896e1823975cdbf12eb63f9e0591328ee235d80e9b5bf1aa6a44f4617ff3caf6400eb172d.txt|text/plain|sha512-LUCKBxfsGIFYJ4p5bGiQRDYdxv3eKNbwSXO4CJbhgjl1zb8S62P54FkTKO4jXYDptb8apqRPRhf/PK9kAOsXLQ==|`)
|
||||
b.AssertFileContent("public/index.html", `T3: ab|/rocks/hugo.187ef4436122d1cc2f40dc2b92f0eba0.txt|text/plain|md5-GH70Q2Ei0cwvQNwrkvDroA==|`)
|
||||
b.AssertFileContent("public/index.html", `T4: sha256-Hgu9bGhroFC46wP/7txk/cnYCUf86CGrvl1tyNJSxaw=|`)
|
||||
|
||||
}},
|
||||
// https://github.com/gohugoio/hugo/issues/5226
|
||||
{"baseurl-path", func() bool { return true }, func(b *sitesBuilder) {
|
||||
@@ -615,7 +598,6 @@ T1: {{ $r1.Permalink }}|{{ $r1.RelPermalink }}
|
||||
`)
|
||||
}, func(b *sitesBuilder) {
|
||||
b.AssertFileContent("public/index.html", `T1: https://example.com/hugo/rocks/hugo.txt|/hugo/rocks/hugo.txt`)
|
||||
|
||||
}},
|
||||
|
||||
// https://github.com/gohugoio/hugo/issues/4944
|
||||
@@ -629,7 +611,6 @@ Inline: {{ $cssInline.Content }}
|
||||
Publish 1: {{ $cssPublish1.Content }} {{ $cssPublish1.RelPermalink }}
|
||||
Publish 2: {{ $cssPublish2.Permalink }}
|
||||
`)
|
||||
|
||||
}, func(b *sitesBuilder) {
|
||||
b.AssertFileContent("public/index.html",
|
||||
`Inline: body{color:green}`,
|
||||
@@ -766,7 +747,6 @@ $color: #333;
|
||||
test.prepare(b)
|
||||
b.Build(BuildCfg{})
|
||||
test.verify(b)
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -785,7 +765,6 @@ func TestMultiSiteResource(t *testing.T) {
|
||||
c.Assert(b.CheckExists("public/en/text/pipes.txt"), qt.Equals, false)
|
||||
b.AssertFileContent("public/en/index.html", "Default Home Page", "String Resource: /blog/text/pipes.txt")
|
||||
b.AssertFileContent("public/text/pipes.txt", "Hugo Pipes")
|
||||
|
||||
}
|
||||
|
||||
func TestResourcesMatch(t *testing.T) {
|
||||
@@ -842,7 +821,6 @@ Hello2: Hello
|
||||
Hello1: Bonjour
|
||||
Hello2: Bonjour
|
||||
`)
|
||||
|
||||
}
|
||||
|
||||
func TestResourceChainPostCSS(t *testing.T) {
|
||||
@@ -971,7 +949,6 @@ Styles Content: Len: 770878|
|
||||
|
||||
b.Assert(strings.Contains(content, "class-in-a"), qt.Equals, true)
|
||||
b.Assert(strings.Contains(content, "class-in-b"), qt.Equals, true)
|
||||
|
||||
}
|
||||
|
||||
assertCss(b)
|
||||
@@ -1031,7 +1008,6 @@ class-in-b {
|
||||
build("always", true)
|
||||
build("fallback", true)
|
||||
build("never", true)
|
||||
|
||||
}
|
||||
|
||||
func TestResourceMinifyDisabled(t *testing.T) {
|
||||
|
Reference in New Issue
Block a user