mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-21 21:35:28 +02:00
tests: Convert from testify to quicktest
This commit is contained in:
@@ -29,9 +29,9 @@ import (
|
||||
|
||||
"github.com/gohugoio/hugo/deps"
|
||||
|
||||
qt "github.com/frankban/quicktest"
|
||||
"github.com/gohugoio/hugo/config"
|
||||
"github.com/gohugoio/hugo/hugofs"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
var logger = loggers.NewErrorLogger()
|
||||
@@ -179,19 +179,19 @@ func doTestI18nTranslate(t testing.TB, test i18nTest, cfg config.Provider) strin
|
||||
}
|
||||
|
||||
func prepareTranslationProvider(t testing.TB, test i18nTest, cfg config.Provider) *TranslationProvider {
|
||||
assert := require.New(t)
|
||||
c := qt.New(t)
|
||||
fs := hugofs.NewMem(cfg)
|
||||
|
||||
for file, content := range test.data {
|
||||
err := afero.WriteFile(fs.Source, filepath.Join("i18n", file), []byte(content), 0755)
|
||||
assert.NoError(err)
|
||||
c.Assert(err, qt.IsNil)
|
||||
}
|
||||
|
||||
tp := NewTranslationProvider()
|
||||
depsCfg := newDepsConfig(tp, cfg, fs)
|
||||
d, err := deps.New(depsCfg)
|
||||
assert.NoError(err)
|
||||
assert.NoError(d.LoadResources())
|
||||
c.Assert(err, qt.IsNil)
|
||||
c.Assert(d.LoadResources(), qt.IsNil)
|
||||
|
||||
return tp
|
||||
}
|
||||
@@ -233,6 +233,7 @@ func getConfig() *viper.Viper {
|
||||
}
|
||||
|
||||
func TestI18nTranslate(t *testing.T) {
|
||||
c := qt.New(t)
|
||||
var actual, expected string
|
||||
v := getConfig()
|
||||
|
||||
@@ -247,7 +248,7 @@ func TestI18nTranslate(t *testing.T) {
|
||||
expected = test.expected
|
||||
}
|
||||
actual = doTestI18nTranslate(t, test, v)
|
||||
require.Equal(t, expected, actual)
|
||||
c.Assert(actual, qt.Equals, expected)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -16,11 +16,12 @@ package langs
|
||||
import (
|
||||
"testing"
|
||||
|
||||
qt "github.com/frankban/quicktest"
|
||||
"github.com/spf13/viper"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestGetGlobalOnlySetting(t *testing.T) {
|
||||
c := qt.New(t)
|
||||
v := viper.New()
|
||||
v.Set("defaultContentLanguageInSubdir", true)
|
||||
v.Set("contentDir", "content")
|
||||
@@ -29,12 +30,12 @@ func TestGetGlobalOnlySetting(t *testing.T) {
|
||||
lang.Set("defaultContentLanguageInSubdir", false)
|
||||
lang.Set("paginatePath", "side")
|
||||
|
||||
require.True(t, lang.GetBool("defaultContentLanguageInSubdir"))
|
||||
require.Equal(t, "side", lang.GetString("paginatePath"))
|
||||
c.Assert(lang.GetBool("defaultContentLanguageInSubdir"), qt.Equals, true)
|
||||
c.Assert(lang.GetString("paginatePath"), qt.Equals, "side")
|
||||
}
|
||||
|
||||
func TestLanguageParams(t *testing.T) {
|
||||
assert := require.New(t)
|
||||
c := qt.New(t)
|
||||
|
||||
v := viper.New()
|
||||
v.Set("p1", "p1cfg")
|
||||
@@ -43,6 +44,6 @@ func TestLanguageParams(t *testing.T) {
|
||||
lang := NewDefaultLanguage(v)
|
||||
lang.SetParam("p1", "p1p")
|
||||
|
||||
assert.Equal("p1p", lang.Params()["p1"])
|
||||
assert.Equal("p1cfg", lang.Get("p1"))
|
||||
c.Assert(lang.Params()["p1"], qt.Equals, "p1p")
|
||||
c.Assert(lang.Get("p1"), qt.Equals, "p1cfg")
|
||||
}
|
||||
|
Reference in New Issue
Block a user