mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-17 21:01:26 +02:00
Optimize the multilanguage build process
Work In Progress! This commit makes a rework of the build and rebuild process to better suit a multi-site setup. This also includes a complete overhaul of the site tests. Previous these were a messy mix that were testing just small parts of the build chain, some of it testing code-paths not even used in "real life". Now all tests that depends on a built site follows the same and real production code path. See #2309 Closes #2211 Closes #477 Closes #1744
This commit is contained in:
@@ -37,37 +37,20 @@ const SITEMAP_TEMPLATE = `<urlset xmlns="http://www.sitemaps.org/schemas/sitemap
|
||||
</urlset>`
|
||||
|
||||
func TestSitemapOutput(t *testing.T) {
|
||||
viper.Reset()
|
||||
defer viper.Reset()
|
||||
|
||||
hugofs.InitMemFs()
|
||||
testCommonResetState()
|
||||
|
||||
viper.Set("baseurl", "http://auth/bub/")
|
||||
|
||||
s := &Site{
|
||||
Source: &source.InMemorySource{ByteSource: weightedSources},
|
||||
Lang: newDefaultLanguage(),
|
||||
Source: &source.InMemorySource{ByteSource: weightedSources},
|
||||
Language: newDefaultLanguage(),
|
||||
}
|
||||
|
||||
s.initializeSiteInfo()
|
||||
|
||||
s.prepTemplates("sitemap.xml", SITEMAP_TEMPLATE)
|
||||
|
||||
createPagesAndMeta(t, s)
|
||||
|
||||
if err := s.renderHomePage(); err != nil {
|
||||
t.Fatalf("Unable to RenderHomePage: %s", err)
|
||||
if err := buildAndRenderSite(s, "sitemap.xml", SITEMAP_TEMPLATE); err != nil {
|
||||
t.Fatalf("Failed to build site: %s", err)
|
||||
}
|
||||
|
||||
if err := s.renderSitemap(); err != nil {
|
||||
t.Fatalf("Unable to RenderSitemap: %s", err)
|
||||
}
|
||||
|
||||
if err := s.renderRobotsTXT(); err != nil {
|
||||
t.Fatalf("Unable to RenderRobotsTXT :%s", err)
|
||||
}
|
||||
|
||||
sitemapFile, err := hugofs.Destination().Open("sitemap.xml")
|
||||
sitemapFile, err := hugofs.Destination().Open("public/sitemap.xml")
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("Unable to locate: sitemap.xml")
|
||||
|
Reference in New Issue
Block a user