Update circle ci for MySQL tests.

This commit is contained in:
go-jet 2019-08-08 10:51:59 +02:00
parent fbf5fbddbc
commit 4c5584aaae
8 changed files with 77 additions and 53 deletions

View file

@ -1,7 +1,6 @@
package jet
import (
"fmt"
"gotest.tools/assert"
"testing"
)
@ -106,9 +105,6 @@ func assertStatement(t *testing.T, query Statement, expectedQuery string, expect
queryStr, args, err := query.Sql()
assert.NilError(t, err)
fmt.Println(queryStr)
//fmt.Println(queryStr)
assert.Equal(t, queryStr, expectedQuery)
assert.DeepEqual(t, args, expectedArgs)
}

View file

@ -8,27 +8,14 @@ import (
"github.com/go-jet/jet/internal/jet"
"gotest.tools/assert"
"io/ioutil"
"os"
"path/filepath"
"runtime"
"strings"
"testing"
"time"
)
func JsonPrint(v interface{}) {
jsonText, _ := json.MarshalIndent(v, "", "\t")
fmt.Println(string(jsonText))
}
func JsonSave(v interface{}, path string) {
jsonText, _ := json.MarshalIndent(v, "", "\t")
err := ioutil.WriteFile(path, jsonText, 0644)
if err != nil {
panic(err)
}
}
func AssertExec(t *testing.T, stmt jet.Statement, db execution.DB, rowsAffected ...int64) {
res, err := stmt.Exec(db)
@ -47,6 +34,16 @@ func AssertExecErr(t *testing.T, stmt jet.Statement, db execution.DB, errorStr s
assert.Error(t, err, errorStr)
}
func getFullPath(relativePath string) string {
goPath := os.Getenv("GOPATH")
return filepath.Join(goPath, "src/github.com/go-jet/jet/tests", relativePath)
}
func PrintJson(v interface{}) {
jsonText, _ := json.MarshalIndent(v, "", "\t")
fmt.Println(string(jsonText))
}
func AssertJSON(t *testing.T, data interface{}, expectedJSON string) {
jsonData, err := json.MarshalIndent(data, "", "\t")
assert.NilError(t, err)
@ -54,8 +51,21 @@ func AssertJSON(t *testing.T, data interface{}, expectedJSON string) {
assert.Equal(t, "\n"+string(jsonData)+"\n", expectedJSON)
}
func AssertJSONFile(t *testing.T, data interface{}, jsonFilePath string) {
fileJSONData, err := ioutil.ReadFile(jsonFilePath)
func SaveJsonFile(v interface{}, testRelativePath string) {
jsonText, _ := json.MarshalIndent(v, "", "\t")
filePath := getFullPath(testRelativePath)
err := ioutil.WriteFile(filePath, jsonText, 0644)
if err != nil {
panic(err)
}
}
func AssertJSONFile(t *testing.T, data interface{}, testRelativePath string) {
filePath := getFullPath(testRelativePath)
fileJSONData, err := ioutil.ReadFile(filePath)
assert.NilError(t, err)
if runtime.GOOS == "windows" {