diff --git a/config.go b/config.go index 411bfe0..8c2dbe3 100644 --- a/config.go +++ b/config.go @@ -386,7 +386,6 @@ func (a *goBlog) initConfig(logging bool) error { if err := a.initDatabase(logging); err != nil { return err } - // Check config // Parse addresses and hostnames if a.cfg.Server.PublicAddress == "" { return errors.New("no public address configured") @@ -505,6 +504,10 @@ func (a *goBlog) initConfig(logging bool) error { } // Check config for each blog for blog, bc := range a.cfg.Blogs { + // Check pagination + if bc.Pagination == 0 { + bc.Pagination = 10 + } // Check sections and add section if none exists if len(bc.Sections) == 0 { bc.Sections = createDefaultSections() diff --git a/config_test.go b/config_test.go index f0c8188..6810fef 100644 --- a/config_test.go +++ b/config_test.go @@ -5,6 +5,7 @@ import ( "testing" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func createDefaultTestConfig(t *testing.T) *config { @@ -138,3 +139,16 @@ func Test_configHttps(t *testing.T) { }) } + +func Test_configDefaults(t *testing.T) { + t.Run("Pagination", func(t *testing.T) { + app := &goBlog{} + err := app.initConfig(false) + require.NoError(t, err) + if assert.Len(t, app.cfg.Blogs, 1) { + for _, bc := range app.cfg.Blogs { + assert.Equal(t, 10, bc.Pagination) + } + } + }) +}