Implement the first generic JSON output testcase

This commit is contained in:
Bjørn Erik Pedersen
2017-03-08 13:45:33 +01:00
parent 3ec5fc3504
commit c8fff9501d
13 changed files with 188 additions and 56 deletions

View File

@@ -17,6 +17,10 @@ import (
"reflect"
"testing"
"github.com/stretchr/testify/require"
"fmt"
"github.com/spf13/hugo/output"
)
@@ -41,3 +45,48 @@ func TestDefaultOutputDefinitions(t *testing.T) {
})
}
}
func TestSiteWithJSONHomepage(t *testing.T) {
t.Parallel()
siteConfig := `
baseURL = "http://example.com/blog"
paginate = 1
defaultContentLanguage = "en"
disableKinds = ["page", "section", "taxonomy", "taxonomyTerm", "RSS", "sitemap", "robotsTXT", "404"]
[Taxonomies]
tag = "tags"
category = "categories"
`
pageTemplate := `---
title: "%s"
outputs: ["json"]
---
# Doc
`
th, h := newTestSitesFromConfigWithDefaultTemplates(t, siteConfig)
require.Len(t, h.Sites, 1)
fs := th.Fs
writeSource(t, fs, "content/_index.md", fmt.Sprintf(pageTemplate, "JSON Home"))
err := h.Build(BuildCfg{})
require.NoError(t, err)
s := h.Sites[0]
home := s.getPage(KindHome)
require.NotNil(t, home)
require.Len(t, home.outputTypes, 1)
th.assertFileContent("public/index.json", "TODO")
}