Improve code coverage.
This commit is contained in:
parent
acd9d20339
commit
f5287628aa
15 changed files with 155 additions and 79 deletions
|
|
@ -6,6 +6,7 @@ import (
|
|||
"fmt"
|
||||
"github.com/go-jet/jet/execution"
|
||||
"github.com/go-jet/jet/internal/jet"
|
||||
"github.com/go-jet/jet/internal/utils"
|
||||
"gotest.tools/assert"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
|
@ -60,9 +61,7 @@ func SaveJSONFile(v interface{}, testRelativePath string) {
|
|||
filePath := getFullPath(testRelativePath)
|
||||
err := ioutil.WriteFile(filePath, jsonText, 0644)
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
utils.PanicOnError(err)
|
||||
}
|
||||
|
||||
// AssertJSONFile check if data json representation is the same as json at testRelativePath
|
||||
|
|
@ -160,6 +159,7 @@ func AssertQueryPanicErr(t *testing.T, stmt jet.Statement, db execution.DB, dest
|
|||
stmt.Query(db, dest)
|
||||
}
|
||||
|
||||
// AssertFileContent check if file content at filePath contains expectedContent text.
|
||||
func AssertFileContent(t *testing.T, filePath string, contentBegin string, expectedContent string) {
|
||||
enumFileData, err := ioutil.ReadFile(filePath)
|
||||
|
||||
|
|
@ -172,6 +172,7 @@ func AssertFileContent(t *testing.T, filePath string, contentBegin string, expec
|
|||
assert.DeepEqual(t, string(enumFileData[beginIndex:]), expectedContent)
|
||||
}
|
||||
|
||||
// AssertFileNamesEqual check if all filesInfos are contained in fileNames
|
||||
func AssertFileNamesEqual(t *testing.T, fileInfos []os.FileInfo, fileNames ...string) {
|
||||
assert.Equal(t, len(fileInfos), len(fileNames))
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package testutils
|
||||
|
||||
import (
|
||||
"github.com/go-jet/jet/internal/utils"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
|
@ -9,9 +10,7 @@ import (
|
|||
func Date(t string) *time.Time {
|
||||
newTime, err := time.Parse("2006-01-02", t)
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
utils.PanicOnError(err)
|
||||
|
||||
return &newTime
|
||||
}
|
||||
|
|
@ -27,9 +26,7 @@ func TimestampWithoutTimeZone(t string, precision int) *time.Time {
|
|||
|
||||
newTime, err := time.Parse("2006-01-02 15:04:05"+precisionStr+" +0000", t+" +0000")
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
utils.PanicOnError(err)
|
||||
|
||||
return &newTime
|
||||
}
|
||||
|
|
@ -38,9 +35,7 @@ func TimestampWithoutTimeZone(t string, precision int) *time.Time {
|
|||
func TimeWithoutTimeZone(t string) *time.Time {
|
||||
newTime, err := time.Parse("15:04:05", t)
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
utils.PanicOnError(err)
|
||||
|
||||
return &newTime
|
||||
}
|
||||
|
|
@ -49,9 +44,7 @@ func TimeWithoutTimeZone(t string) *time.Time {
|
|||
func TimeWithTimeZone(t string) *time.Time {
|
||||
newTimez, err := time.Parse("15:04:05 -0700", t)
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
utils.PanicOnError(err)
|
||||
|
||||
return &newTimez
|
||||
}
|
||||
|
|
@ -67,9 +60,7 @@ func TimestampWithTimeZone(t string, precision int) *time.Time {
|
|||
|
||||
newTime, err := time.Parse("2006-01-02 15:04:05"+precisionStr+" -0700 MST", t)
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
utils.PanicOnError(err)
|
||||
|
||||
return &newTime
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue