summaryrefslogtreecommitdiffhomepage
path: root/hugolib
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2019-09-06 09:28:43 +0200
committerBjørn Erik Pedersen <[email protected]>2019-09-06 11:04:57 +0200
commit9442937d82005b369780edcc557e0d15d6bf0bad (patch)
tree270776dff37cd161a56253a0284ad07bcb70af37 /hugolib
parent901077c0364eaf3fe4f997c3026aa18cfc7781ed (diff)
downloadhugo-9442937d82005b369780edcc557e0d15d6bf0bad.tar.gz
hugo-9442937d82005b369780edcc557e0d15d6bf0bad.zip
Avoid writing the same processed image to /public twice
Fixes #6307
Diffstat (limited to 'hugolib')
-rw-r--r--hugolib/image_test.go3
-rw-r--r--hugolib/testhelpers_test.go8
2 files changed, 11 insertions, 0 deletions
diff --git a/hugolib/image_test.go b/hugolib/image_test.go
index 4db57e4a5..a13338afc 100644
--- a/hugolib/image_test.go
+++ b/hugolib/image_test.go
@@ -211,4 +211,7 @@ SUNSET2: {{ $resized2.RelPermalink }}/{{ $resized2.Width }}/Lat: {{ $resized2.Ex
b.AssertFileContent("resources/_gen/images/sunset_17701188623491591036.json",
"DateTimeDigitized|time.Time", "PENTAX")
+ // TODO(bep) add this as a default assertion after Build()?
+ b.AssertNoDuplicateWrites()
+
}
diff --git a/hugolib/testhelpers_test.go b/hugolib/testhelpers_test.go
index 6e62a2442..6e00a8ee0 100644
--- a/hugolib/testhelpers_test.go
+++ b/hugolib/testhelpers_test.go
@@ -486,6 +486,8 @@ func (s *sitesBuilder) CreateSitesE() error {
return errors.Wrap(err, "failed to load config")
}
+ s.Fs.Destination = hugofs.NewCreateCountingFs(s.Fs.Destination)
+
depsCfg := s.depsCfg
depsCfg.Fs = s.Fs
depsCfg.Cfg = s.Cfg
@@ -680,6 +682,12 @@ func (s *sitesBuilder) AssertImage(width, height int, filename string) {
s.Assert(cfg.Height, qt.Equals, height)
}
+func (s *sitesBuilder) AssertNoDuplicateWrites() {
+ s.Helper()
+ d := s.Fs.Destination.(hugofs.DuplicatesReporter)
+ s.Assert(d.ReportDuplicates(), qt.Equals, "")
+}
+
func (s *sitesBuilder) FileContent(filename string) string {
s.T.Helper()
filename = filepath.FromSlash(filename)