Additional qrm tests.
This commit is contained in:
parent
9a3f12ea5f
commit
947d2df47e
4 changed files with 39 additions and 9 deletions
|
|
@ -94,7 +94,7 @@ jobs:
|
||||||
|
|
||||||
|
|
||||||
- run: mkdir -p $TEST_RESULTS
|
- run: mkdir -p $TEST_RESULTS
|
||||||
- run: go test -v ./... -coverpkg=github.com/go-jet/jet/postgres/...,github.com/go-jet/jet/mysql/...,github.com/go-jet/jet/execution/...,github.com/go-jet/jet/generator/...,github.com/go-jet/jet/internal/... -coverprofile=cover.out 2>&1 | go-junit-report > $TEST_RESULTS/results.xml
|
- run: go test -v ./... -coverpkg=github.com/go-jet/jet/postgres/...,github.com/go-jet/jet/mysql/...,github.com/go-jet/jet/qrm/...,github.com/go-jet/jet/generator/...,github.com/go-jet/jet/internal/... -coverprofile=cover.out 2>&1 | go-junit-report > $TEST_RESULTS/results.xml
|
||||||
|
|
||||||
- run:
|
- run:
|
||||||
name: Upload code coverage
|
name: Upload code coverage
|
||||||
|
|
|
||||||
|
|
@ -156,6 +156,7 @@ func valueToString(value reflect.Value) string {
|
||||||
|
|
||||||
var timeType = reflect.TypeOf(time.Now())
|
var timeType = reflect.TypeOf(time.Now())
|
||||||
var uuidType = reflect.TypeOf(uuid.New())
|
var uuidType = reflect.TypeOf(uuid.New())
|
||||||
|
var byteArrayType = reflect.TypeOf([]byte(""))
|
||||||
|
|
||||||
func isSimpleModelType(objType reflect.Type) bool {
|
func isSimpleModelType(objType reflect.Type) bool {
|
||||||
objType = indirectType(objType)
|
objType = indirectType(objType)
|
||||||
|
|
@ -167,15 +168,9 @@ func isSimpleModelType(objType reflect.Type) bool {
|
||||||
reflect.String,
|
reflect.String,
|
||||||
reflect.Bool:
|
reflect.Bool:
|
||||||
return true
|
return true
|
||||||
case reflect.Slice:
|
|
||||||
return objType.Elem().Kind() == reflect.Uint8 //[]byte
|
|
||||||
case reflect.Struct:
|
|
||||||
return objType == timeType
|
|
||||||
case reflect.Array:
|
|
||||||
return objType == uuidType // uuid.UUID returns reflect.Array kind
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return objType == timeType || objType == uuidType || objType == byteArrayType
|
||||||
}
|
}
|
||||||
|
|
||||||
func isIntegerType(value reflect.Type) bool {
|
func isIntegerType(value reflect.Type) bool {
|
||||||
|
|
|
||||||
35
qrm/utill_test.go
Normal file
35
qrm/utill_test.go
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
package qrm
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"gotest.tools/assert"
|
||||||
|
"reflect"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestIsSimpleModelType(t *testing.T) {
|
||||||
|
assert.Assert(t, isSimpleModelType(reflect.TypeOf(int8(11))))
|
||||||
|
assert.Assert(t, isSimpleModelType(reflect.TypeOf(int16(11))))
|
||||||
|
assert.Assert(t, isSimpleModelType(reflect.TypeOf(int32(11))))
|
||||||
|
assert.Assert(t, isSimpleModelType(reflect.TypeOf(int64(11))))
|
||||||
|
assert.Assert(t, isSimpleModelType(reflect.TypeOf(uint8(11))))
|
||||||
|
assert.Assert(t, isSimpleModelType(reflect.TypeOf(uint16(11))))
|
||||||
|
assert.Assert(t, isSimpleModelType(reflect.TypeOf(uint32(11))))
|
||||||
|
assert.Assert(t, isSimpleModelType(reflect.TypeOf(uint64(11))))
|
||||||
|
|
||||||
|
assert.Assert(t, isSimpleModelType(reflect.TypeOf(float32(123.46))))
|
||||||
|
assert.Assert(t, isSimpleModelType(reflect.TypeOf(float64(123.46))))
|
||||||
|
|
||||||
|
assert.Assert(t, isSimpleModelType(reflect.TypeOf([]byte("Text"))))
|
||||||
|
assert.Assert(t, isSimpleModelType(reflect.TypeOf(time.Now())))
|
||||||
|
assert.Assert(t, isSimpleModelType(reflect.TypeOf(uuid.New())))
|
||||||
|
|
||||||
|
complexModelType := struct {
|
||||||
|
Field1 string
|
||||||
|
Field2 string
|
||||||
|
}{}
|
||||||
|
|
||||||
|
assert.Equal(t, isSimpleModelType(reflect.TypeOf(complexModelType)), false)
|
||||||
|
assert.Equal(t, isSimpleModelType(reflect.TypeOf(&complexModelType)), false)
|
||||||
|
}
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit 1f6bd8bb86458019fa43b1e2cd7ae9488a7ac9a4
|
Subproject commit 02e0795d1e06b959d0c564dc1e349159d57b1bf6
|
||||||
Loading…
Add table
Add a link
Reference in a new issue