sdbc/insert_scope_test.go

25 lines
486 B
Go
Raw Normal View History

2023-09-10 16:07:03 +00:00
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,
2023-09-16 10:09:34 +00:00
Debug: true,
2023-09-10 16:13:23 +00:00
}).BindModel(&ModelArticles{})
2023-09-10 16:07:03 +00:00
var doc = &ModelArticles{
Title: "hello world1",
CreateTime: time.Now().Unix(),
}
2023-09-16 10:09:34 +00:00
err := driver.Insert().Insert(doc)
2023-09-10 16:07:03 +00:00
assert.NoError(t, err)
t.Logf("doc id: %v", doc.Id)
}