Refactor user tests and add content and order tests
- Updated user_test.go to remove FocusConvey and clean up commented-out code. - Introduced content_test.go with comprehensive tests for content creation, updating, pricing, asset attachment, and access checks. - Added order_test.go to implement tests for order management, including admin top-ups, order details, refunds, and content purchases with various scenarios.
This commit is contained in:
@@ -101,7 +101,7 @@ func (t *UserTestSuite) Test_FindByUsername() {
|
||||
|
||||
// Test_Page
|
||||
func (t *UserTestSuite) Test_Page() {
|
||||
FocusConvey("test page", t.T(), func() {
|
||||
Convey("test page", t.T(), func() {
|
||||
Convey("filter username", func() {
|
||||
database.Truncate(t.T().Context(), t.DB, models.TableNameUser)
|
||||
|
||||
@@ -124,7 +124,7 @@ func (t *UserTestSuite) Test_Page() {
|
||||
So(pager.Total, ShouldEqual, 1)
|
||||
})
|
||||
|
||||
FocusConvey("filter tenant users", func() {
|
||||
Convey("filter tenant users", func() {
|
||||
database.Truncate(
|
||||
t.T().Context(),
|
||||
t.DB,
|
||||
@@ -205,53 +205,6 @@ func (t *UserTestSuite) Test_Page() {
|
||||
|
||||
func (t *UserTestSuite) Test_Relations() {
|
||||
Convey("test page", t.T(), func() {
|
||||
// database.Truncate(
|
||||
// t.T().Context(),
|
||||
// t.DB,
|
||||
// models.TableNameUser,
|
||||
// models.TableNameTenant,
|
||||
// models.TableNameTenantUser,
|
||||
// )
|
||||
|
||||
// username := "test-user"
|
||||
// mUser01 := &models.User{
|
||||
// Username: username,
|
||||
// Password: "test-password",
|
||||
// Roles: types.NewArray([]consts.Role{consts.RoleUser}),
|
||||
// Status: consts.UserStatusPendingVerify,
|
||||
// }
|
||||
|
||||
// err := mUser01.Create(t.T().Context())
|
||||
// So(err, ShouldBeNil)
|
||||
|
||||
// tenantModel := &models.Tenant{
|
||||
// UserID: 1,
|
||||
// Code: "abc",
|
||||
// UUID: types.NewUUIDv4(),
|
||||
// Name: "T01",
|
||||
// Status: consts.TenantStatusVerified,
|
||||
// }
|
||||
|
||||
// err = tenantModel.Create(t.T().Context())
|
||||
// So(err, ShouldBeNil)
|
||||
|
||||
// count := 10
|
||||
// for i := 0; i < count; i++ {
|
||||
// mUser := &models.User{
|
||||
// Username: fmt.Sprintf("user_%d", i),
|
||||
// Password: "test-password",
|
||||
// Roles: types.NewArray([]consts.Role{consts.RoleUser}),
|
||||
// Status: consts.UserStatusPendingVerify,
|
||||
// }
|
||||
|
||||
// err = mUser.Create(t.T().Context())
|
||||
// So(err, ShouldBeNil)
|
||||
|
||||
// // create tenant user
|
||||
// err = Tenant.AddUser(t.T().Context(), 1, mUser.ID)
|
||||
// So(err, ShouldBeNil)
|
||||
// }
|
||||
|
||||
Convey("filter tenant users", func() {
|
||||
m, err := User.FindByID(t.T().Context(), 1)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
Reference in New Issue
Block a user