51 lines
1.1 KiB
Go
51 lines
1.1 KiB
Go
package services
|
|
|
|
import (
|
|
"database/sql"
|
|
"testing"
|
|
|
|
"quyun/v2/app/commands/testx"
|
|
"quyun/v2/database"
|
|
"quyun/v2/database/models"
|
|
"quyun/v2/pkg/utils"
|
|
|
|
. "github.com/smartystreets/goconvey/convey"
|
|
"github.com/stretchr/testify/suite"
|
|
|
|
_ "go.ipao.vip/atom"
|
|
"go.ipao.vip/atom/contracts"
|
|
"go.uber.org/dig"
|
|
)
|
|
|
|
type TenantTestSuiteInjectParams struct {
|
|
dig.In
|
|
|
|
DB *sql.DB
|
|
Initials []contracts.Initial `group:"initials"` // nolint:structcheck
|
|
}
|
|
|
|
type TenantTestSuite struct {
|
|
suite.Suite
|
|
|
|
TenantTestSuiteInjectParams
|
|
}
|
|
|
|
func Test_Tenant(t *testing.T) {
|
|
providers := testx.Default().With(Provide)
|
|
|
|
testx.Serve(providers, t, func(p TenantTestSuiteInjectParams) {
|
|
suite.Run(t, &TenantTestSuite{TenantTestSuiteInjectParams: p})
|
|
})
|
|
}
|
|
|
|
func (t *TenantTestSuite) Test_TenantUserCount() {
|
|
Convey("test get tenants user count", t.T(), func() {
|
|
database.Truncate(t.T().Context(), t.DB, models.TableNameTenant)
|
|
|
|
result, err := Tenant.TenantUserCountMapping(t.T().Context(), []int64{1, 2})
|
|
So(err, ShouldBeNil)
|
|
So(result, ShouldHaveLength, 2)
|
|
t.T().Logf("%s", utils.MustJsonString(result))
|
|
})
|
|
}
|