Browse Source

add mymysql tests (#656)

tags/v0.6.3
Lunny Xiao GitHub 2 years ago
parent
commit
a5a917d477
4 changed files with 15 additions and 10 deletions
  1. +1
    -1
      circle.yml
  2. +12
    -9
      session_get_test.go
  3. +1
    -0
      test_mymysql.sh
  4. +1
    -0
      xorm_test.go

+ 1
- 1
circle.yml View File

@@ -21,7 +21,7 @@ database:
test:
override:
# './...' is a relative pattern which means all subdirectories
- go test -v -race -db="sqlite3::mysql::postgres" -conn_str="./test.db::root:@/xorm_test::dbname=xorm_test sslmode=disable" -coverprofile=coverage.txt -covermode=atomic
- go test -v -race -db="sqlite3::mysql::mymysql::postgres" -conn_str="./test.db::root:@/xorm_test::xorm_test/root/::dbname=xorm_test sslmode=disable" -coverprofile=coverage.txt -covermode=atomic
- cd /home/ubuntu/.go_workspace/src/github.com/go-xorm/tests && ./sqlite3.sh
- cd /home/ubuntu/.go_workspace/src/github.com/go-xorm/tests && ./mysql.sh
- cd /home/ubuntu/.go_workspace/src/github.com/go-xorm/tests && ./postgres.sh


+ 12
- 9
session_get_test.go View File

@@ -71,15 +71,18 @@ func TestGetVar(t *testing.T) {
assert.Equal(t, "28", valuesString["age"])
assert.Equal(t, "1.5", valuesString["money"])

var valuesInter = make(map[string]interface{})
has, err = testEngine.Table("get_var").Where("id = ?", 1).Select("*").Get(&valuesInter)
assert.NoError(t, err)
assert.Equal(t, true, has)
assert.Equal(t, 5, len(valuesInter))
assert.EqualValues(t, 1, valuesInter["id"])
assert.Equal(t, "hi", fmt.Sprintf("%s", valuesInter["msg"]))
assert.EqualValues(t, 28, valuesInter["age"])
assert.Equal(t, "1.5", fmt.Sprintf("%v", valuesInter["money"]))
// for mymysql driver, interface{} will be []byte, so ignore it currently
if testEngine.dialect.DriverName() != "mymysql" {
var valuesInter = make(map[string]interface{})
has, err = testEngine.Table("get_var").Where("id = ?", 1).Select("*").Get(&valuesInter)
assert.NoError(t, err)
assert.Equal(t, true, has)
assert.Equal(t, 5, len(valuesInter))
assert.EqualValues(t, 1, valuesInter["id"])
assert.Equal(t, "hi", fmt.Sprintf("%s", valuesInter["msg"]))
assert.EqualValues(t, 28, valuesInter["age"])
assert.Equal(t, "1.5", fmt.Sprintf("%v", valuesInter["money"]))
}

var valuesSliceString = make([]string, 5)
has, err = testEngine.Table("get_var").Get(&valuesSliceString)


+ 1
- 0
test_mymysql.sh View File

@@ -0,0 +1 @@
go test -db=mymysql -conn_str="xorm_test/root/"

+ 1
- 0
xorm_test.go View File

@@ -12,6 +12,7 @@ import (
"github.com/go-xorm/core"
_ "github.com/lib/pq"
_ "github.com/mattn/go-sqlite3"
_ "github.com/ziutek/mymysql/godrv"
)

var (


Loading…
Cancel
Save