session_insert_test.go 600 B

12345678910111213141516171819202122232425262728
  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. "testing"
  7. "time"
  8. "github.com/stretchr/testify/assert"
  9. )
  10. func TestInsertOne(t *testing.T) {
  11. assert.NoError(t, prepareEngine())
  12. type Test struct {
  13. Id int64 `xorm:"autoincr pk"`
  14. Msg string `xorm:"varchar(255)"`
  15. Created time.Time `xorm:"created"`
  16. }
  17. assert.NoError(t, testEngine.Sync2(new(Test)))
  18. data := Test{Msg: "hi"}
  19. _, err := testEngine.InsertOne(data)
  20. assert.NoError(t, err)
  21. }