Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2022-02-09 18:37:21 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2022-02-09 18:38:12 +0300
commitf60714b5a139553c0bcbcd6319c4603d7e35a099 (patch)
treed3a808546bd0f57a7f2cc627563f7f6b0b3bd8b3 /hugolib
parent215a715ddd698731fd81aed9cfaf7e37826e2467 (diff)
Add a migration test helper
Diffstat (limited to 'hugolib')
-rw-r--r--hugolib/testhelpers_test.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/hugolib/testhelpers_test.go b/hugolib/testhelpers_test.go
index 105654c4f..e03ea5363 100644
--- a/hugolib/testhelpers_test.go
+++ b/hugolib/testhelpers_test.go
@@ -5,6 +5,7 @@ import (
"fmt"
"image/jpeg"
"io"
+ "io/fs"
"math/rand"
"os"
"path/filepath"
@@ -702,6 +703,34 @@ func (s *sitesBuilder) AssertFileContentFn(filename string, f func(s string) boo
}
}
+// Helper to migrate tests to new format.
+func (s *sitesBuilder) DumpTxtar() string {
+ var sb strings.Builder
+
+ skipRe := regexp.MustCompile(`^(public|resources|package-lock.json|go.sum)`)
+
+ afero.Walk(s.Fs.Source, s.workingDir, func(path string, info fs.FileInfo, err error) error {
+ rel := strings.TrimPrefix(path, s.workingDir+"/")
+ if skipRe.MatchString(rel) {
+ if info.IsDir() {
+ return filepath.SkipDir
+ }
+ return nil
+ }
+ if info == nil || info.IsDir() {
+ return nil
+ }
+ sb.WriteString(fmt.Sprintf("-- %s --\n", rel))
+ b, err := afero.ReadFile(s.Fs.Source, path)
+ s.Assert(err, qt.IsNil)
+ sb.WriteString(strings.TrimSpace(string(b)))
+ sb.WriteString("\n")
+ return nil
+ })
+
+ return sb.String()
+}
+
func (s *sitesBuilder) AssertHome(matches ...string) {
s.AssertFileContent("public/index.html", matches...)
}