mirror of
				https://github.com/gohugoio/hugo.git
				synced 2024-05-11 05:54:58 +00:00 
			
		
		
		
	Stop Viper from leaking across many of the tests (now tests pass regardless of order tested)
This commit is contained in:
		@@ -431,6 +431,8 @@ func TestExists(t *testing.T) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestAbsPathify(t *testing.T) {
 | 
			
		||||
	defer viper.Reset()
 | 
			
		||||
 | 
			
		||||
	type test struct {
 | 
			
		||||
		inPath, workingDir, expected string
 | 
			
		||||
	}
 | 
			
		||||
@@ -450,6 +452,7 @@ func TestAbsPathify(t *testing.T) {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for i, d := range data {
 | 
			
		||||
		viper.Reset()
 | 
			
		||||
		// todo see comment in AbsPathify
 | 
			
		||||
		viper.Set("WorkingDir", d.workingDir)
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,9 @@
 | 
			
		||||
package helpers
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"github.com/spf13/viper"
 | 
			
		||||
	"testing"
 | 
			
		||||
 | 
			
		||||
	"github.com/spf13/viper"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func TestParsePygmentsArgs(t *testing.T) {
 | 
			
		||||
@@ -20,6 +21,7 @@ func TestParsePygmentsArgs(t *testing.T) {
 | 
			
		||||
		{"boo=invalid", "foo", false, false},
 | 
			
		||||
		{"style", "foo", false, false},
 | 
			
		||||
	} {
 | 
			
		||||
		viper.Reset()
 | 
			
		||||
		viper.Set("PygmentsStyle", this.pygmentsStyle)
 | 
			
		||||
		viper.Set("PygmentsUseClasses", this.pygmentsUseClasses)
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,10 +1,11 @@
 | 
			
		||||
package helpers
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"github.com/spf13/viper"
 | 
			
		||||
	"github.com/stretchr/testify/assert"
 | 
			
		||||
	"strings"
 | 
			
		||||
	"testing"
 | 
			
		||||
 | 
			
		||||
	"github.com/spf13/viper"
 | 
			
		||||
	"github.com/stretchr/testify/assert"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func TestURLize(t *testing.T) {
 | 
			
		||||
@@ -28,6 +29,7 @@ func TestURLize(t *testing.T) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestAbsURL(t *testing.T) {
 | 
			
		||||
	defer viper.Reset()
 | 
			
		||||
	tests := []struct {
 | 
			
		||||
		input    string
 | 
			
		||||
		baseURL  string
 | 
			
		||||
@@ -41,6 +43,7 @@ func TestAbsURL(t *testing.T) {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for _, test := range tests {
 | 
			
		||||
		viper.Reset()
 | 
			
		||||
		viper.Set("BaseURL", test.baseURL)
 | 
			
		||||
		output := AbsURL(test.input)
 | 
			
		||||
		if output != test.expected {
 | 
			
		||||
@@ -50,7 +53,8 @@ func TestAbsURL(t *testing.T) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestRelURL(t *testing.T) {
 | 
			
		||||
	defer viper.Set("canonifyURLs", viper.GetBool("canonifyURLs"))
 | 
			
		||||
	defer viper.Reset()
 | 
			
		||||
	//defer viper.Set("canonifyURLs", viper.GetBool("canonifyURLs"))
 | 
			
		||||
	tests := []struct {
 | 
			
		||||
		input    string
 | 
			
		||||
		baseURL  string
 | 
			
		||||
@@ -70,6 +74,7 @@ func TestRelURL(t *testing.T) {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for i, test := range tests {
 | 
			
		||||
		viper.Reset()
 | 
			
		||||
		viper.Set("BaseURL", test.baseURL)
 | 
			
		||||
		viper.Set("canonifyURLs", test.canonify)
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user