26 lines
548 B
Go
26 lines
548 B
Go
|
package sdbc
|
||
|
|
||
|
import (
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
"testing"
|
||
|
"time"
|
||
|
)
|
||
|
|
||
|
func Test_insert_InsertOne(t *testing.T) {
|
||
|
var driver = NewSDBC(&Config{
|
||
|
Dbname: "test.db",
|
||
|
MaxIdleConn: 10,
|
||
|
MaxOpenConn: 100,
|
||
|
MaxLifetime: time.Hour,
|
||
|
})
|
||
|
err := driver.GetClient().AutoMigrate(&ModelArticles{})
|
||
|
assert.NoError(t, err)
|
||
|
var doc = &ModelArticles{
|
||
|
Title: "hello world1",
|
||
|
CreateTime: time.Now().Unix(),
|
||
|
}
|
||
|
err = driver.BindModel(&ModelArticles{}).Insert().InsertOne(doc)
|
||
|
assert.NoError(t, err)
|
||
|
t.Logf("doc id: %v", doc.Id)
|
||
|
}
|