diff --git a/hugolib/site_test.go b/hugolib/site_test.go index 68fb5e5fc..482e2f791 100644 --- a/hugolib/site_test.go +++ b/hugolib/site_test.go @@ -21,6 +21,7 @@ import ( "path/filepath" "strings" "testing" + "time" "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) { if err := s.CreatePages(); err != nil { t.Fatalf("Unable to create pages: %s", err)