aboutsummaryrefslogtreecommitdiffhomepage
path: root/hugolib/hugo_sites_test.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2016-08-08 09:05:16 +0200
committerBjørn Erik Pedersen <[email protected]>2016-09-06 18:32:18 +0300
commit6b552db75f00cae14377e38327fd168f6398f22d (patch)
tree1a7ecfea92864ca34dc80e483371d6d9b8844dec /hugolib/hugo_sites_test.go
parente56ecab1575f1b25552988b9efff2836f05f87f9 (diff)
downloadhugo-6b552db75f00cae14377e38327fd168f6398f22d.tar.gz
hugo-6b552db75f00cae14377e38327fd168f6398f22d.zip
Make sure drafts etc. are not processed
See #2309
Diffstat (limited to 'hugolib/hugo_sites_test.go')
-rw-r--r--hugolib/hugo_sites_test.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/hugolib/hugo_sites_test.go b/hugolib/hugo_sites_test.go
index e2a110d18..655feba0f 100644
--- a/hugolib/hugo_sites_test.go
+++ b/hugolib/hugo_sites_test.go
@@ -1,6 +1,7 @@
package hugolib
import (
+ "bytes"
"fmt"
"strings"
"testing"
@@ -141,6 +142,9 @@ func TestMultiSitesBuild(t *testing.T) {
assert.False(t, strings.Contains(string(doc1en.Content), "&laquo;"), string(doc1en.Content))
assert.True(t, strings.Contains(string(doc1en.Content), "&ldquo;"), string(doc1en.Content))
+ // Check that the drafts etc. are not built/processed/rendered.
+ assertShouldNotBuild(t, sites)
+
}
func TestMultiSitesRebuild(t *testing.T) {
@@ -303,6 +307,30 @@ func TestMultiSitesRebuild(t *testing.T) {
this.assertFunc(t)
}
+
+ // Check that the drafts etc. are not built/processed/rendered.
+ assertShouldNotBuild(t, sites)
+
+}
+
+func assertShouldNotBuild(t *testing.T, sites *HugoSites) {
+ s := sites.Sites[0]
+
+ for _, p := range s.rawAllPages {
+ // No HTML when not processed
+ require.Equal(t, p.shouldBuild(), bytes.Contains(p.rawContent, []byte("</")), p.BaseFileName()+": "+string(p.rawContent))
+ require.Equal(t, p.shouldBuild(), p.Content != "", p.BaseFileName())
+
+ require.Equal(t, p.shouldBuild(), p.Content != "", p.BaseFileName())
+
+ filename := filepath.Join("public", p.TargetPath())
+ if strings.HasSuffix(filename, ".html") {
+ // TODO(bep) the end result is correct, but it is weird that we cannot use targetPath directly here.
+ filename = strings.Replace(filename, ".html", "/index.html", 1)
+ }
+
+ require.Equal(t, p.shouldBuild(), destinationExists(filename), filename)
+ }
}
func TestAddNewLanguage(t *testing.T) {
@@ -579,6 +607,14 @@ func readDestination(t *testing.T, filename string) string {
return readFileFromFs(t, hugofs.Destination(), filename)
}
+func destinationExists(filename string) bool {
+ b, err := helpers.Exists(filename, hugofs.Destination())
+ if err != nil {
+ panic(err)
+ }
+ return b
+}
+
func readSource(t *testing.T, filename string) string {
return readFileFromFs(t, hugofs.Source(), filename)
}