mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-23 21:53:09 +02:00
tests: Convert from testify to quicktest
This commit is contained in:
@@ -15,12 +15,14 @@ package commands
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
qt "github.com/frankban/quicktest"
|
||||
)
|
||||
|
||||
func TestParseJekyllFilename(t *testing.T) {
|
||||
c := qt.New(t)
|
||||
filenameArray := []string{
|
||||
"2015-01-02-test.md",
|
||||
"2012-03-15-中文.markup",
|
||||
@@ -36,13 +38,14 @@ func TestParseJekyllFilename(t *testing.T) {
|
||||
|
||||
for i, filename := range filenameArray {
|
||||
postDate, postName, err := parseJekyllFilename(filename)
|
||||
assert.Equal(t, err, nil)
|
||||
assert.Equal(t, expectResult[i].postDate.Format("2006-01-02"), postDate.Format("2006-01-02"))
|
||||
assert.Equal(t, expectResult[i].postName, postName)
|
||||
c.Assert(err, qt.IsNil)
|
||||
c.Assert(expectResult[i].postDate.Format("2006-01-02"), qt.Equals, postDate.Format("2006-01-02"))
|
||||
c.Assert(expectResult[i].postName, qt.Equals, postName)
|
||||
}
|
||||
}
|
||||
|
||||
func TestConvertJekyllMetadata(t *testing.T) {
|
||||
c := qt.New(t)
|
||||
testDataList := []struct {
|
||||
metadata interface{}
|
||||
postName string
|
||||
@@ -73,14 +76,15 @@ func TestConvertJekyllMetadata(t *testing.T) {
|
||||
|
||||
for _, data := range testDataList {
|
||||
result, err := convertJekyllMetaData(data.metadata, data.postName, data.postDate, data.draft)
|
||||
assert.Equal(t, nil, err)
|
||||
c.Assert(err, qt.IsNil)
|
||||
jsonResult, err := json.Marshal(result)
|
||||
assert.Equal(t, nil, err)
|
||||
assert.Equal(t, data.expect, string(jsonResult))
|
||||
c.Assert(err, qt.IsNil)
|
||||
c.Assert(string(jsonResult), qt.Equals, data.expect)
|
||||
}
|
||||
}
|
||||
|
||||
func TestConvertJekyllContent(t *testing.T) {
|
||||
c := qt.New(t)
|
||||
testDataList := []struct {
|
||||
metadata interface{}
|
||||
content string
|
||||
@@ -124,6 +128,6 @@ func TestConvertJekyllContent(t *testing.T) {
|
||||
|
||||
for _, data := range testDataList {
|
||||
result := convertJekyllContent(data.metadata, data.content)
|
||||
assert.Equal(t, data.expect, result)
|
||||
c.Assert(data.expect, qt.Equals, result)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user