mdbc/mdbc_test.go

48 lines
1006 B
Go
Raw Normal View History

2023-06-22 15:14:51 +00:00
package mdbc
import (
"context"
"github.com/stretchr/testify/assert"
"gitter.top/common/goref"
"go.mongodb.org/mongo-driver/bson"
"testing"
)
func newDriver() *mdbc {
return NewMDBC(&Config{
Address: "192.168.3.21",
Port: 0,
Username: "admin",
Password: "admin",
ProcessTimeout: 0,
ReadPref: 0,
DbName: "articles",
})
}
func TestNewMDBC(t *testing.T) {
driver := newDriver()
databases, err := driver.GetClient().ListDatabaseNames(context.Background(), bson.D{})
assert.NoError(t, err)
t.Log(databases)
}
func TestScope_Count(t *testing.T) {
driver := newDriver()
article := driver.BindModel(&ModelArticles{})
value, err := article.Count().SetContext(context.Background()).Count()
assert.NoError(t, err)
t.Log(value)
}
func TestDropScope_Do(t *testing.T) {
driver := newDriver()
article := driver.BindModel(&ModelArticles{})
err := article.Drop().Do()
assert.NoError(t, err)
}
func TestInsertScope_Insert(t *testing.T) {
}