diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-02-05 10:20:06 +0700 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-02-17 17:15:26 +0100 |
commit | 93ca7c9e958e34469a337e4efcc7c75774ec50fd (patch) | |
tree | 5dfa296cfe74fd5ef8f0d41ea4078704f453aa04 /helpers/pygments_test.go | |
parent | e34af6ee30f70f5780a281e2fd8f4ed9b487ee61 (diff) |
all: Refactor to nonglobal Viper, i18n etc.
This is a final rewrite that removes all the global state in Hugo, which also enables
the use if `t.Parallel` in tests.
Updates #2701
Fixes #3016
Diffstat (limited to 'helpers/pygments_test.go')
-rw-r--r-- | helpers/pygments_test.go | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/helpers/pygments_test.go b/helpers/pygments_test.go index 1cca68eac..1fce17859 100644 --- a/helpers/pygments_test.go +++ b/helpers/pygments_test.go @@ -34,11 +34,12 @@ 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) - result1, err := parsePygmentsOpts(this.in) + v := viper.New() + v.Set("pygmentsStyle", this.pygmentsStyle) + v.Set("pygmentsUseClasses", this.pygmentsUseClasses) + + result1, err := parsePygmentsOpts(v, this.in) if b, ok := this.expect1.(bool); ok && !b { if err == nil { t.Errorf("[%d] parsePygmentArgs didn't return an expected error", i) @@ -70,19 +71,19 @@ func TestParseDefaultPygmentsArgs(t *testing.T) { {"style=foo,noclasses=false", nil, nil, "style=override,noclasses=override"}, {"style=foo,noclasses=false", "override", false, "style=override,noclasses=override"}, } { - viper.Reset() + v := viper.New() - viper.Set("pygmentsOptions", this.pygmentsOptions) + v.Set("pygmentsOptions", this.pygmentsOptions) if s, ok := this.pygmentsStyle.(string); ok { - viper.Set("pygmentsStyle", s) + v.Set("pygmentsStyle", s) } if b, ok := this.pygmentsUseClasses.(bool); ok { - viper.Set("pygmentsUseClasses", b) + v.Set("pygmentsUseClasses", b) } - result, err := parsePygmentsOpts(this.in) + result, err := parsePygmentsOpts(v, this.in) if err != nil { t.Errorf("[%d] parsePygmentArgs failed: %s", i, err) continue |