Browse Source

add test for InsertOne to confirm

xormplus 8 years ago
parent
commit
6a6f02a044
1 changed files with 28 additions and 0 deletions
  1. 28 0
      session_insert_test.go

+ 28 - 0
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)
+}