add test for InsertOne to confirm #545

This commit is contained in:
Lunny Xiao 2017-03-26 21:26:02 +08:00
parent aa18589b49
commit bdb225ceb5
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
1 changed files with 28 additions and 0 deletions

28
session_insert_test.go Normal file
View File

@ -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)
}