sdbc/delete_scope_test.go
2023-09-16 18:09:34 +08:00

37 lines
788 B
Go

package sdbc
import (
"github.com/stretchr/testify/assert"
"testing"
"time"
)
func Test__delete_DeleteByID(t *testing.T) {
var driver = NewSDBC(&Config{
Dbname: "test.db",
MaxIdleConn: 10,
MaxOpenConn: 100,
MaxLifetime: time.Hour,
Debug: true,
}).BindModel(&ModelArticles{})
var doc = &ModelArticles{
Title: "hello world1",
CreateTime: time.Now().Unix(),
}
err := driver.Delete().DeleteByID(1)
assert.NoError(t, err)
t.Logf("doc id: %v", doc.Id)
}
func Test__delete_Delete(t *testing.T) {
var driver = NewSDBC(&Config{
Dbname: "test.db",
MaxIdleConn: 10,
MaxOpenConn: 100,
MaxLifetime: time.Hour,
Debug: true,
}).BindModel(&ModelArticles{})
err := driver.Delete().SetWhere("id = ?", 2).Delete()
assert.NoError(t, err)
}