diff options
author | spf13 <steve.francia@gmail.com> | 2015-05-20 02:21:21 -0400 |
---|---|---|
committer | spf13 <steve.francia@gmail.com> | 2015-05-20 02:21:21 -0400 |
commit | a584ff207b4ee951e4b25cf5cedf6d261ee1bc47 (patch) | |
tree | 4273e35cfd90493ed0d25d53450285b61c527418 /hugolib/pagination_test.go | |
parent | 599d1b9786ddbaa9203aaca2c96ab33b40a583b1 (diff) |
Stop Viper from leaking across many of the tests (now tests pass regardless of order tested)
Diffstat (limited to 'hugolib/pagination_test.go')
-rw-r--r-- | hugolib/pagination_test.go | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/hugolib/pagination_test.go b/hugolib/pagination_test.go index e76709fdb..d9fc15c95 100644 --- a/hugolib/pagination_test.go +++ b/hugolib/pagination_test.go @@ -2,12 +2,13 @@ package hugolib import ( "fmt" - "github.com/spf13/hugo/source" - "github.com/spf13/viper" - "github.com/stretchr/testify/assert" "html/template" "path/filepath" "testing" + + "github.com/spf13/hugo/source" + "github.com/spf13/viper" + "github.com/stretchr/testify/assert" ) func TestSplitPages(t *testing.T) { @@ -100,6 +101,9 @@ func TestPagerNoPages(t *testing.T) { } func TestPaginationURLFactory(t *testing.T) { + viper.Reset() + defer viper.Reset() + viper.Set("PaginatePath", "zoo") unicode := newPaginationURLFactory("новости проекта") fooBar := newPaginationURLFactory("foo", "bar") @@ -112,12 +116,18 @@ func TestPaginationURLFactory(t *testing.T) { } func TestPaginator(t *testing.T) { + viper.Reset() + defer viper.Reset() + for _, useViper := range []bool{false, true} { doTestPaginator(t, useViper) } } func doTestPaginator(t *testing.T, useViper bool) { + viper.Reset() + defer viper.Reset() + pagerSize := 5 if useViper { viper.Set("paginate", pagerSize) @@ -159,6 +169,9 @@ func doTestPaginator(t *testing.T, useViper bool) { } func TestPaginatorWithNegativePaginate(t *testing.T) { + viper.Reset() + defer viper.Reset() + viper.Set("paginate", -1) s := &Site{} _, err := s.newHomeNode().Paginator() @@ -166,6 +179,9 @@ func TestPaginatorWithNegativePaginate(t *testing.T) { } func TestPaginate(t *testing.T) { + viper.Reset() + defer viper.Reset() + for _, useViper := range []bool{false, true} { doTestPaginate(t, useViper) } @@ -224,6 +240,9 @@ func TestInvalidOptions(t *testing.T) { } func TestPaginateWithNegativePaginate(t *testing.T) { + viper.Reset() + defer viper.Reset() + viper.Set("paginate", -1) s := &Site{} _, err := s.newHomeNode().Paginate(createTestPages(2)) @@ -243,6 +262,9 @@ func TestPaginatePages(t *testing.T) { // Issue #993 func TestPaginatorFollowedByPaginateShouldFail(t *testing.T) { + viper.Reset() + defer viper.Reset() + viper.Set("paginate", 10) s := &Site{} n1 := s.newHomeNode() @@ -259,6 +281,8 @@ func TestPaginatorFollowedByPaginateShouldFail(t *testing.T) { } func TestPaginateFollowedByDifferentPaginateShouldFail(t *testing.T) { + viper.Reset() + defer viper.Reset() viper.Set("paginate", 10) s := &Site{} |