Simple and Powerful ORM for Go, support mysql,postgres,tidb,sqlite3,mssql,oracle https://xorm.io
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
931B

  1. // Copyright 2017 The Xorm Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package xorm
  5. import (
  6. "database/sql"
  7. "testing"
  8. "github.com/stretchr/testify/assert"
  9. )
  10. func TestClose(t *testing.T) {
  11. assert.NoError(t, prepareEngine())
  12. sess1 := testEngine.NewSession()
  13. sess1.Close()
  14. assert.True(t, sess1.IsClosed())
  15. sess2 := testEngine.Where("a = ?", 1)
  16. sess2.Close()
  17. assert.True(t, sess2.IsClosed())
  18. }
  19. func TestNullFloatStruct(t *testing.T) {
  20. type MyNullFloat64 sql.NullFloat64
  21. type MyNullFloatStruct struct {
  22. Uuid string
  23. Amount MyNullFloat64
  24. }
  25. assert.NoError(t, prepareEngine())
  26. assert.NoError(t, testEngine.Sync2(new(MyNullFloatStruct)))
  27. _, err := testEngine.Insert(&MyNullFloatStruct{
  28. Uuid: "111111",
  29. Amount: MyNullFloat64(sql.NullFloat64{
  30. Float64: 0.1111,
  31. Valid: true,
  32. }),
  33. })
  34. assert.NoError(t, err)
  35. }