Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tpl/os
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-08-10 22:05:17 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-08-12 14:26:32 +0300
commit9e571827055dedb46b78c5db3d17d6913f14870b (patch)
treef5f0108afe0c9385ff6dc27664943d9f719f57ad /tpl/os
parent6027ee11082d0b9d72de1d4d1980a702be294ad2 (diff)
tests: Convert from testify to quicktest
Diffstat (limited to 'tpl/os')
-rw-r--r--tpl/os/init_test.go8
-rw-r--r--tpl/os/os_test.go35
2 files changed, 21 insertions, 22 deletions
diff --git a/tpl/os/init_test.go b/tpl/os/init_test.go
index 08d816cdf..6a91c743a 100644
--- a/tpl/os/init_test.go
+++ b/tpl/os/init_test.go
@@ -16,12 +16,14 @@ package os
import (
"testing"
+ qt "github.com/frankban/quicktest"
"github.com/gohugoio/hugo/deps"
+ "github.com/gohugoio/hugo/htesting/hqt"
"github.com/gohugoio/hugo/tpl/internal"
- "github.com/stretchr/testify/require"
)
func TestInit(t *testing.T) {
+ c := qt.New(t)
var found bool
var ns *internal.TemplateFuncsNamespace
@@ -33,6 +35,6 @@ func TestInit(t *testing.T) {
}
}
- require.True(t, found)
- require.IsType(t, &Namespace{}, ns.Context())
+ c.Assert(found, qt.Equals, true)
+ c.Assert(ns.Context(), hqt.IsSameType, &Namespace{})
}
diff --git a/tpl/os/os_test.go b/tpl/os/os_test.go
index 46dafd842..3adb6f8c2 100644
--- a/tpl/os/os_test.go
+++ b/tpl/os/os_test.go
@@ -14,20 +14,19 @@
package os
import (
- "fmt"
"path/filepath"
"testing"
+ qt "github.com/frankban/quicktest"
"github.com/gohugoio/hugo/deps"
"github.com/gohugoio/hugo/hugofs"
"github.com/spf13/afero"
"github.com/spf13/viper"
- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/require"
)
func TestReadFile(t *testing.T) {
t.Parallel()
+ c := qt.New(t)
workingDir := "/home/hugo"
@@ -40,7 +39,7 @@ func TestReadFile(t *testing.T) {
afero.WriteFile(ns.deps.Fs.Source, filepath.Join(workingDir, "/f/f1.txt"), []byte("f1-content"), 0755)
afero.WriteFile(ns.deps.Fs.Source, filepath.Join("/home", "f2.txt"), []byte("f2-content"), 0755)
- for i, test := range []struct {
+ for _, test := range []struct {
filename string
expect interface{}
}{
@@ -50,22 +49,22 @@ func TestReadFile(t *testing.T) {
{"", false},
{"b", false},
} {
- errMsg := fmt.Sprintf("[%d] %v", i, test)
result, err := ns.ReadFile(test.filename)
if b, ok := test.expect.(bool); ok && !b {
- require.Error(t, err, errMsg)
+ c.Assert(err, qt.Not(qt.IsNil))
continue
}
- require.NoError(t, err, errMsg)
- assert.Equal(t, test.expect, result, errMsg)
+ c.Assert(err, qt.IsNil)
+ c.Assert(result, qt.Equals, test.expect)
}
}
func TestFileExists(t *testing.T) {
t.Parallel()
+ c := qt.New(t)
workingDir := "/home/hugo"
@@ -77,7 +76,7 @@ func TestFileExists(t *testing.T) {
afero.WriteFile(ns.deps.Fs.Source, filepath.Join(workingDir, "/f/f1.txt"), []byte("f1-content"), 0755)
afero.WriteFile(ns.deps.Fs.Source, filepath.Join("/home", "f2.txt"), []byte("f2-content"), 0755)
- for i, test := range []struct {
+ for _, test := range []struct {
filename string
expect interface{}
}{
@@ -87,22 +86,21 @@ func TestFileExists(t *testing.T) {
{"b", false},
{"", nil},
} {
- errMsg := fmt.Sprintf("[%d] %v", i, test)
result, err := ns.FileExists(test.filename)
if test.expect == nil {
- require.Error(t, err, errMsg)
+ c.Assert(err, qt.Not(qt.IsNil))
continue
}
- require.NoError(t, err, errMsg)
- assert.Equal(t, test.expect, result, errMsg)
+ c.Assert(err, qt.IsNil)
+ c.Assert(result, qt.Equals, test.expect)
}
}
func TestStat(t *testing.T) {
t.Parallel()
-
+ c := qt.New(t)
workingDir := "/home/hugo"
v := viper.New()
@@ -112,7 +110,7 @@ func TestStat(t *testing.T) {
afero.WriteFile(ns.deps.Fs.Source, filepath.Join(workingDir, "/f/f1.txt"), []byte("f1-content"), 0755)
- for i, test := range []struct {
+ for _, test := range []struct {
filename string
expect interface{}
}{
@@ -121,15 +119,14 @@ func TestStat(t *testing.T) {
{"b", nil},
{"", nil},
} {
- errMsg := fmt.Sprintf("[%d] %v", i, test)
result, err := ns.Stat(test.filename)
if test.expect == nil {
- require.Error(t, err, errMsg)
+ c.Assert(err, qt.Not(qt.IsNil))
continue
}
- require.NoError(t, err, errMsg)
- assert.Equal(t, test.expect, result.Size(), errMsg)
+ c.Assert(err, qt.IsNil)
+ c.Assert(result.Size(), qt.Equals, test.expect)
}
}