Add test for Hugo hanging up with empty content

This adds a test for the issue #1797 and its fix in 68e2e63.
This commit is contained in:
Tatsushi Demachi 2016-02-08 20:55:19 +09:00
parent d1b0290fef
commit 2b3b90a6df

View file

@ -21,6 +21,7 @@ import (
"path/filepath" "path/filepath"
"strings" "strings"
"testing" "testing"
"time"
"bitbucket.org/pkg/inflect" "bitbucket.org/pkg/inflect"
@ -64,6 +65,37 @@ more text
` `
) )
// Issue #1797
func TestReadPagesFromSourceWithEmptySource(t *testing.T) {
viper.Reset()
defer viper.Reset()
viper.Set("DefaultExtension", "html")
viper.Set("verbose", true)
viper.Set("baseurl", "http://auth/bub")
sources := []source.ByteSource{}
s := &Site{
Source: &source.InMemorySource{ByteSource: sources},
Targets: targetList{Page: &target.PagePub{UglyURLs: true}},
}
var err error
d := time.Second * 2
ticker := time.NewTicker(d)
select {
case err = <-s.ReadPagesFromSource():
break
case <-ticker.C:
err = fmt.Errorf("ReadPagesFromSource() never returns in %s", d.String())
}
ticker.Stop()
if err != nil {
t.Fatalf("Unable to read source: %s", err)
}
}
func createAndRenderPages(t *testing.T, s *Site) { func createAndRenderPages(t *testing.T, s *Site) {
if err := s.CreatePages(); err != nil { if err := s.CreatePages(); err != nil {
t.Fatalf("Unable to create pages: %s", err) t.Fatalf("Unable to create pages: %s", err)