diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2019-08-10 21:05:17 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2019-08-12 13:26:32 +0200 |
commit | 9e571827055dedb46b78c5db3d17d6913f14870b (patch) | |
tree | f5f0108afe0c9385ff6dc27664943d9f719f57ad /tpl/data/resources_test.go | |
parent | 6027ee11082d0b9d72de1d4d1980a702be294ad2 (diff) |
tests: Convert from testify to quicktest
Diffstat (limited to 'tpl/data/resources_test.go')
-rw-r--r-- | tpl/data/resources_test.go | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/tpl/data/resources_test.go b/tpl/data/resources_test.go index e9850c226..aec5a2e8c 100644 --- a/tpl/data/resources_test.go +++ b/tpl/data/resources_test.go @@ -15,7 +15,6 @@ package data import ( "bytes" - "fmt" "net/http" "net/http/httptest" "net/url" @@ -27,6 +26,7 @@ import ( "github.com/gohugoio/hugo/helpers" + qt "github.com/frankban/quicktest" "github.com/gohugoio/hugo/cache/filecache" "github.com/gohugoio/hugo/common/loggers" "github.com/gohugoio/hugo/config" @@ -35,8 +35,6 @@ import ( "github.com/gohugoio/hugo/langs" "github.com/spf13/afero" "github.com/spf13/viper" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func TestScpGetLocal(t *testing.T) { @@ -88,6 +86,7 @@ func getTestServer(handler func(w http.ResponseWriter, r *http.Request)) (*httpt func TestScpGetRemote(t *testing.T) { t.Parallel() + c := qt.New(t) fs := new(afero.MemMapFs) cache := filecache.NewCache(fs, 100, "") @@ -102,10 +101,10 @@ func TestScpGetRemote(t *testing.T) { } for _, test := range tests { - msg := fmt.Sprintf("%v", test) + msg := qt.Commentf("%v", test) req, err := http.NewRequest("GET", test.path, nil) - require.NoError(t, err, msg) + c.Assert(err, qt.IsNil, msg) srv, cl := getTestServer(func(w http.ResponseWriter, r *http.Request) { w.Write(test.content) @@ -115,23 +114,24 @@ func TestScpGetRemote(t *testing.T) { ns := newTestNs() ns.client = cl - var c []byte + var cb []byte f := func(b []byte) (bool, error) { - c = b + cb = b return false, nil } err = ns.getRemote(cache, f, req) - require.NoError(t, err, msg) - assert.Equal(t, string(test.content), string(c)) + c.Assert(err, qt.IsNil, msg) + c.Assert(string(cb), qt.Equals, string(test.content)) - assert.Equal(t, string(test.content), string(c)) + c.Assert(string(cb), qt.Equals, string(test.content)) } } func TestScpGetRemoteParallel(t *testing.T) { t.Parallel() + c := qt.New(t) content := []byte(`T€st Content 123`) srv, cl := getTestServer(func(w http.ResponseWriter, r *http.Request) { @@ -142,7 +142,7 @@ func TestScpGetRemoteParallel(t *testing.T) { url := "http://Foo.Bar/foo_Bar-Foo" req, err := http.NewRequest("GET", url, nil) - require.NoError(t, err) + c.Assert(err, qt.IsNil) for _, ignoreCache := range []bool{false} { cfg := viper.New() @@ -159,16 +159,16 @@ func TestScpGetRemoteParallel(t *testing.T) { go func(gor int) { defer wg.Done() for j := 0; j < 10; j++ { - var c []byte + var cb []byte f := func(b []byte) (bool, error) { - c = b + cb = b return false, nil } err := ns.getRemote(ns.cacheGetJSON, f, req) - assert.NoError(t, err) - if string(content) != string(c) { - t.Errorf("expected\n%q\ngot\n%q", content, c) + c.Assert(err, qt.IsNil) + if string(content) != string(cb) { + t.Errorf("expected\n%q\ngot\n%q", content, cb) } time.Sleep(23 * time.Millisecond) |