From bdb225ceb5dcbed5c12b39d21bcfa71f2c04cd91 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sun, 26 Mar 2017 21:26:02 +0800 Subject: [PATCH] add test for InsertOne to confirm #545 --- session_insert_test.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 session_insert_test.go diff --git a/session_insert_test.go b/session_insert_test.go new file mode 100644 index 00000000..b232d3f7 --- /dev/null +++ b/session_insert_test.go @@ -0,0 +1,28 @@ +// Copyright 2017 The Xorm Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package xorm + +import ( + "testing" + "time" + + "github.com/stretchr/testify/assert" +) + +func TestInsertOne(t *testing.T) { + assert.NoError(t, prepareEngine()) + + type Test struct { + Id int64 `xorm:"autoincr pk"` + Msg string `xorm:"varchar(255)"` + Created time.Time `xorm:"created"` + } + + assert.NoError(t, testEngine.Sync2(new(Test))) + + data := Test{Msg: "hi"} + _, err := testEngine.InsertOne(data) + assert.NoError(t, err) +}