Make the config loading testable

This is needed to verify  #2309, but it closes a big hole in Hugo's automated tests.

The loading of the config is now moved to `hugolib` and the same default settings are now used
in production and tests.

As Viper now uses Afero as its filesystem, we now can write fairly complete integration tests with ease.

See #2309
This commit is contained in:
Bjørn Erik Pedersen
2016-08-05 11:04:52 +02:00
parent b6fcb3d0bb
commit 36f2a1f676
3 changed files with 146 additions and 12 deletions

View File

@@ -29,18 +29,8 @@ func init() {
func testCommonResetState() {
hugofs.InitMemFs()
viper.Reset()
viper.Set("ContentDir", "content")
viper.Set("DataDir", "data")
viper.Set("I18nDir", "i18n")
viper.Set("themesDir", "themes")
viper.Set("LayoutDir", "layouts")
viper.Set("PublishDir", "public")
viper.Set("RSSUri", "rss")
viper.Set("Taxonomies", map[string]interface{}{
"tag": "tags",
"category": "categories",
})
viper.SetFs(hugofs.Source())
loadDefaultSettings()
if err := hugofs.Source().Mkdir("content", 0755); err != nil {
panic("Content folder creation failed.")