|
@@ -16,7 +16,7 @@ import (
|
|
|
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
|
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
-// TC-0267: 正常插入
|
|
|
|
|
|
|
+// TC-0281: 正常插入
|
|
|
func TestSysRoleModel_CRUD(t *testing.T) {
|
|
func TestSysRoleModel_CRUD(t *testing.T) {
|
|
|
ctx := context.Background()
|
|
ctx := context.Background()
|
|
|
conn := testutil.GetTestSqlConn()
|
|
conn := testutil.GetTestSqlConn()
|
|
@@ -62,7 +62,7 @@ func TestSysRoleModel_CRUD(t *testing.T) {
|
|
|
assert.True(t, errors.Is(err, ErrNotFound))
|
|
assert.True(t, errors.Is(err, ErrNotFound))
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TC-0327: FindOneByProductCodeName
|
|
|
|
|
|
|
+// TC-0346: FindOneByProductCodeName
|
|
|
func TestSysRoleModel_FindOneByProductCodeName_FoundAndNotFound(t *testing.T) {
|
|
func TestSysRoleModel_FindOneByProductCodeName_FoundAndNotFound(t *testing.T) {
|
|
|
ctx := context.Background()
|
|
ctx := context.Background()
|
|
|
conn := testutil.GetTestSqlConn()
|
|
conn := testutil.GetTestSqlConn()
|
|
@@ -97,7 +97,7 @@ func TestSysRoleModel_FindOneByProductCodeName_FoundAndNotFound(t *testing.T) {
|
|
|
assert.True(t, errors.Is(err, ErrNotFound))
|
|
assert.True(t, errors.Is(err, ErrNotFound))
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TC-0395: 正常分页
|
|
|
|
|
|
|
+// TC-0418: 正常分页
|
|
|
func TestSysRoleModel_FindListByProductCode_Pagination(t *testing.T) {
|
|
func TestSysRoleModel_FindListByProductCode_Pagination(t *testing.T) {
|
|
|
ctx := context.Background()
|
|
ctx := context.Background()
|
|
|
conn := testutil.GetTestSqlConn()
|
|
conn := testutil.GetTestSqlConn()
|
|
@@ -141,7 +141,7 @@ func TestSysRoleModel_FindListByProductCode_Pagination(t *testing.T) {
|
|
|
require.Len(t, list3, 1)
|
|
require.Len(t, list3, 1)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TC-0397: 正常
|
|
|
|
|
|
|
+// TC-0420: 正常
|
|
|
func TestSysRoleModel_FindByIds_NormalEmptyPartial(t *testing.T) {
|
|
func TestSysRoleModel_FindByIds_NormalEmptyPartial(t *testing.T) {
|
|
|
ctx := context.Background()
|
|
ctx := context.Background()
|
|
|
conn := testutil.GetTestSqlConn()
|
|
conn := testutil.GetTestSqlConn()
|
|
@@ -181,7 +181,7 @@ func TestSysRoleModel_FindByIds_NormalEmptyPartial(t *testing.T) {
|
|
|
assert.Equal(t, id1, partial[0].Id)
|
|
assert.Equal(t, id1, partial[0].Id)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TC-0290: 多条记录(3条)
|
|
|
|
|
|
|
+// TC-0307: 多条记录(3条)
|
|
|
func TestSysRoleModel_BatchInsert_BatchDelete(t *testing.T) {
|
|
func TestSysRoleModel_BatchInsert_BatchDelete(t *testing.T) {
|
|
|
ctx := context.Background()
|
|
ctx := context.Background()
|
|
|
conn := testutil.GetTestSqlConn()
|
|
conn := testutil.GetTestSqlConn()
|
|
@@ -218,7 +218,7 @@ func TestSysRoleModel_BatchInsert_BatchDelete(t *testing.T) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TC-0268: 唯一索引冲突
|
|
|
|
|
|
|
+// TC-0283: 唯一索引冲突
|
|
|
func TestSysRoleModel_Insert_DuplicateProductCodeName(t *testing.T) {
|
|
func TestSysRoleModel_Insert_DuplicateProductCodeName(t *testing.T) {
|
|
|
ctx := context.Background()
|
|
ctx := context.Background()
|
|
|
conn := testutil.GetTestSqlConn()
|
|
conn := testutil.GetTestSqlConn()
|
|
@@ -259,14 +259,14 @@ func TestSysRoleModel_Insert_DuplicateProductCodeName(t *testing.T) {
|
|
|
assert.Equal(t, uint16(1062), me.Number)
|
|
assert.Equal(t, uint16(1062), me.Number)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TC-0287: 获取表名
|
|
|
|
|
|
|
+// TC-0304: 获取表名
|
|
|
func TestSysRoleModel_TableName(t *testing.T) {
|
|
func TestSysRoleModel_TableName(t *testing.T) {
|
|
|
conn := testutil.GetTestSqlConn()
|
|
conn := testutil.GetTestSqlConn()
|
|
|
m := NewSysRoleModel(conn, testutil.GetTestCacheConf(), testutil.GetTestCachePrefix())
|
|
m := NewSysRoleModel(conn, testutil.GetTestCacheConf(), testutil.GetTestCachePrefix())
|
|
|
assert.Equal(t, "`sys_role`", m.TableName())
|
|
assert.Equal(t, "`sys_role`", m.TableName())
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TC-0274: 记录不存在
|
|
|
|
|
|
|
+// TC-0290: 记录不存在
|
|
|
func TestSysRoleModel_FindOne_NotFound(t *testing.T) {
|
|
func TestSysRoleModel_FindOne_NotFound(t *testing.T) {
|
|
|
conn := testutil.GetTestSqlConn()
|
|
conn := testutil.GetTestSqlConn()
|
|
|
m := NewSysRoleModel(conn, testutil.GetTestCacheConf(), testutil.GetTestCachePrefix())
|
|
m := NewSysRoleModel(conn, testutil.GetTestCacheConf(), testutil.GetTestCachePrefix())
|
|
@@ -274,7 +274,7 @@ func TestSysRoleModel_FindOne_NotFound(t *testing.T) {
|
|
|
require.ErrorIs(t, err, ErrNotFound)
|
|
require.ErrorIs(t, err, ErrNotFound)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TC-0280: 记录不存在
|
|
|
|
|
|
|
+// TC-0297: 记录不存在
|
|
|
func TestSysRoleModel_Update_NotFound(t *testing.T) {
|
|
func TestSysRoleModel_Update_NotFound(t *testing.T) {
|
|
|
conn := testutil.GetTestSqlConn()
|
|
conn := testutil.GetTestSqlConn()
|
|
|
m := NewSysRoleModel(conn, testutil.GetTestCacheConf(), testutil.GetTestCachePrefix())
|
|
m := NewSysRoleModel(conn, testutil.GetTestCacheConf(), testutil.GetTestCachePrefix())
|
|
@@ -285,7 +285,7 @@ func TestSysRoleModel_Update_NotFound(t *testing.T) {
|
|
|
require.ErrorIs(t, err, ErrNotFound)
|
|
require.ErrorIs(t, err, ErrNotFound)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TC-0283: 记录不存在
|
|
|
|
|
|
|
+// TC-0300: 记录不存在
|
|
|
func TestSysRoleModel_Delete_NotFound(t *testing.T) {
|
|
func TestSysRoleModel_Delete_NotFound(t *testing.T) {
|
|
|
conn := testutil.GetTestSqlConn()
|
|
conn := testutil.GetTestSqlConn()
|
|
|
m := NewSysRoleModel(conn, testutil.GetTestCacheConf(), testutil.GetTestCachePrefix())
|
|
m := NewSysRoleModel(conn, testutil.GetTestCacheConf(), testutil.GetTestCachePrefix())
|
|
@@ -293,7 +293,7 @@ func TestSysRoleModel_Delete_NotFound(t *testing.T) {
|
|
|
require.ErrorIs(t, err, ErrNotFound)
|
|
require.ErrorIs(t, err, ErrNotFound)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TC-0288: 空列表
|
|
|
|
|
|
|
+// TC-0305: 空列表
|
|
|
func TestSysRoleModel_BatchInsert_Empty(t *testing.T) {
|
|
func TestSysRoleModel_BatchInsert_Empty(t *testing.T) {
|
|
|
conn := testutil.GetTestSqlConn()
|
|
conn := testutil.GetTestSqlConn()
|
|
|
m := NewSysRoleModel(conn, testutil.GetTestCacheConf(), testutil.GetTestCachePrefix())
|
|
m := NewSysRoleModel(conn, testutil.GetTestCacheConf(), testutil.GetTestCachePrefix())
|
|
@@ -301,7 +301,7 @@ func TestSysRoleModel_BatchInsert_Empty(t *testing.T) {
|
|
|
require.NoError(t, m.BatchInsert(context.Background(), []*SysRole{}))
|
|
require.NoError(t, m.BatchInsert(context.Background(), []*SysRole{}))
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TC-0305: 空ids
|
|
|
|
|
|
|
+// TC-0324: 空ids
|
|
|
func TestSysRoleModel_BatchDelete_Empty(t *testing.T) {
|
|
func TestSysRoleModel_BatchDelete_Empty(t *testing.T) {
|
|
|
conn := testutil.GetTestSqlConn()
|
|
conn := testutil.GetTestSqlConn()
|
|
|
m := NewSysRoleModel(conn, testutil.GetTestCacheConf(), testutil.GetTestCachePrefix())
|
|
m := NewSysRoleModel(conn, testutil.GetTestCacheConf(), testutil.GetTestCachePrefix())
|
|
@@ -309,7 +309,7 @@ func TestSysRoleModel_BatchDelete_Empty(t *testing.T) {
|
|
|
require.NoError(t, m.BatchDelete(context.Background(), []int64{}))
|
|
require.NoError(t, m.BatchDelete(context.Background(), []int64{}))
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TC-0396: 空结果
|
|
|
|
|
|
|
+// TC-0419: 空结果
|
|
|
func TestSysRoleModel_FindListByProductCode_Empty(t *testing.T) {
|
|
func TestSysRoleModel_FindListByProductCode_Empty(t *testing.T) {
|
|
|
conn := testutil.GetTestSqlConn()
|
|
conn := testutil.GetTestSqlConn()
|
|
|
m := NewSysRoleModel(conn, testutil.GetTestCacheConf(), testutil.GetTestCachePrefix())
|
|
m := NewSysRoleModel(conn, testutil.GetTestCacheConf(), testutil.GetTestCachePrefix())
|
|
@@ -319,7 +319,7 @@ func TestSysRoleModel_FindListByProductCode_Empty(t *testing.T) {
|
|
|
require.Len(t, list, 0)
|
|
require.Len(t, list, 0)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TC-0270: 事务内插入
|
|
|
|
|
|
|
+// TC-0285: 事务内插入
|
|
|
func TestSysRoleModel_InsertWithTx_Normal(t *testing.T) {
|
|
func TestSysRoleModel_InsertWithTx_Normal(t *testing.T) {
|
|
|
ctx := context.Background()
|
|
ctx := context.Background()
|
|
|
conn := testutil.GetTestSqlConn()
|
|
conn := testutil.GetTestSqlConn()
|
|
@@ -358,7 +358,7 @@ func TestSysRoleModel_InsertWithTx_Normal(t *testing.T) {
|
|
|
assert.Equal(t, name, got.Name)
|
|
assert.Equal(t, name, got.Name)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TC-0271: 事务回滚后无数据
|
|
|
|
|
|
|
+// TC-0287: 事务回滚后无数据
|
|
|
func TestSysRoleModel_InsertWithTx_Rollback(t *testing.T) {
|
|
func TestSysRoleModel_InsertWithTx_Rollback(t *testing.T) {
|
|
|
ctx := context.Background()
|
|
ctx := context.Background()
|
|
|
conn := testutil.GetTestSqlConn()
|
|
conn := testutil.GetTestSqlConn()
|
|
@@ -388,7 +388,7 @@ func TestSysRoleModel_InsertWithTx_Rollback(t *testing.T) {
|
|
|
require.ErrorIs(t, err, ErrNotFound)
|
|
require.ErrorIs(t, err, ErrNotFound)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TC-0281: 事务内更新
|
|
|
|
|
|
|
+// TC-0298: 事务内更新
|
|
|
func TestSysRoleModel_UpdateWithTx(t *testing.T) {
|
|
func TestSysRoleModel_UpdateWithTx(t *testing.T) {
|
|
|
ctx := context.Background()
|
|
ctx := context.Background()
|
|
|
conn := testutil.GetTestSqlConn()
|
|
conn := testutil.GetTestSqlConn()
|
|
@@ -425,7 +425,7 @@ func TestSysRoleModel_UpdateWithTx(t *testing.T) {
|
|
|
assert.Equal(t, "after_tx", got.Remark)
|
|
assert.Equal(t, "after_tx", got.Remark)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TC-0284: 事务内删除
|
|
|
|
|
|
|
+// TC-0301: 事务内删除
|
|
|
func TestSysRoleModel_DeleteWithTx(t *testing.T) {
|
|
func TestSysRoleModel_DeleteWithTx(t *testing.T) {
|
|
|
ctx := context.Background()
|
|
ctx := context.Background()
|
|
|
conn := testutil.GetTestSqlConn()
|
|
conn := testutil.GetTestSqlConn()
|
|
@@ -456,7 +456,7 @@ func TestSysRoleModel_DeleteWithTx(t *testing.T) {
|
|
|
require.ErrorIs(t, err, ErrNotFound)
|
|
require.ErrorIs(t, err, ErrNotFound)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TC-0285: 正常事务
|
|
|
|
|
|
|
+// TC-0302: 正常事务
|
|
|
func TestSysRoleModel_TransactCtx_CommitAndRollback(t *testing.T) {
|
|
func TestSysRoleModel_TransactCtx_CommitAndRollback(t *testing.T) {
|
|
|
ctx := context.Background()
|
|
ctx := context.Background()
|
|
|
conn := testutil.GetTestSqlConn()
|
|
conn := testutil.GetTestSqlConn()
|
|
@@ -500,7 +500,7 @@ func TestSysRoleModel_TransactCtx_CommitAndRollback(t *testing.T) {
|
|
|
require.ErrorIs(t, err, ErrNotFound)
|
|
require.ErrorIs(t, err, ErrNotFound)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TC-0289: 单条记录
|
|
|
|
|
|
|
+// TC-0306: 单条记录
|
|
|
func TestSysRoleModel_BatchInsert_Single(t *testing.T) {
|
|
func TestSysRoleModel_BatchInsert_Single(t *testing.T) {
|
|
|
ctx := context.Background()
|
|
ctx := context.Background()
|
|
|
conn := testutil.GetTestSqlConn()
|
|
conn := testutil.GetTestSqlConn()
|
|
@@ -520,7 +520,7 @@ func TestSysRoleModel_BatchInsert_Single(t *testing.T) {
|
|
|
assert.Equal(t, name, found.Name)
|
|
assert.Equal(t, name, found.Name)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TC-0291: 唯一索引冲突
|
|
|
|
|
|
|
+// TC-0309: 唯一索引冲突
|
|
|
func TestSysRoleModel_BatchInsert_UniqueConflict(t *testing.T) {
|
|
func TestSysRoleModel_BatchInsert_UniqueConflict(t *testing.T) {
|
|
|
ctx := context.Background()
|
|
ctx := context.Background()
|
|
|
conn := testutil.GetTestSqlConn()
|
|
conn := testutil.GetTestSqlConn()
|
|
@@ -549,7 +549,7 @@ func TestSysRoleModel_BatchInsert_UniqueConflict(t *testing.T) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TC-0296: 空列表
|
|
|
|
|
|
|
+// TC-0314: 空列表
|
|
|
func TestSysRoleModel_BatchUpdate_Empty(t *testing.T) {
|
|
func TestSysRoleModel_BatchUpdate_Empty(t *testing.T) {
|
|
|
conn := testutil.GetTestSqlConn()
|
|
conn := testutil.GetTestSqlConn()
|
|
|
m := NewSysRoleModel(conn, testutil.GetTestCacheConf(), testutil.GetTestCachePrefix())
|
|
m := NewSysRoleModel(conn, testutil.GetTestCacheConf(), testutil.GetTestCachePrefix())
|
|
@@ -557,7 +557,7 @@ func TestSysRoleModel_BatchUpdate_Empty(t *testing.T) {
|
|
|
require.NoError(t, m.BatchUpdate(context.Background(), []*SysRole{}))
|
|
require.NoError(t, m.BatchUpdate(context.Background(), []*SysRole{}))
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TC-0298: 多条记录(3条)
|
|
|
|
|
|
|
+// TC-0316: 多条记录(3条)
|
|
|
func TestSysRoleModel_BatchUpdate_Multi(t *testing.T) {
|
|
func TestSysRoleModel_BatchUpdate_Multi(t *testing.T) {
|
|
|
ctx := context.Background()
|
|
ctx := context.Background()
|
|
|
conn := testutil.GetTestSqlConn()
|
|
conn := testutil.GetTestSqlConn()
|
|
@@ -593,7 +593,7 @@ func TestSysRoleModel_BatchUpdate_Multi(t *testing.T) {
|
|
|
assert.Equal(t, int64(2), g2.Status)
|
|
assert.Equal(t, int64(2), g2.Status)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TC-0294: 正常多条
|
|
|
|
|
|
|
+// TC-0312: 正常多条
|
|
|
func TestSysRoleModel_BatchInsertWithTx_Normal(t *testing.T) {
|
|
func TestSysRoleModel_BatchInsertWithTx_Normal(t *testing.T) {
|
|
|
ctx := context.Background()
|
|
ctx := context.Background()
|
|
|
conn := testutil.GetTestSqlConn()
|
|
conn := testutil.GetTestSqlConn()
|
|
@@ -623,7 +623,7 @@ func TestSysRoleModel_BatchInsertWithTx_Normal(t *testing.T) {
|
|
|
assert.Equal(t, n2, f2.Name)
|
|
assert.Equal(t, n2, f2.Name)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TC-0293: 空列表
|
|
|
|
|
|
|
+// TC-0311: 空列表
|
|
|
func TestSysRoleModel_BatchInsertWithTx_Empty(t *testing.T) {
|
|
func TestSysRoleModel_BatchInsertWithTx_Empty(t *testing.T) {
|
|
|
conn := testutil.GetTestSqlConn()
|
|
conn := testutil.GetTestSqlConn()
|
|
|
m := NewSysRoleModel(conn, testutil.GetTestCacheConf(), testutil.GetTestCachePrefix())
|
|
m := NewSysRoleModel(conn, testutil.GetTestCacheConf(), testutil.GetTestCachePrefix())
|
|
@@ -633,7 +633,7 @@ func TestSysRoleModel_BatchInsertWithTx_Empty(t *testing.T) {
|
|
|
require.NoError(t, err)
|
|
require.NoError(t, err)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TC-0295: 事务回滚
|
|
|
|
|
|
|
+// TC-0313: 事务回滚
|
|
|
func TestSysRoleModel_BatchInsertWithTx_Rollback(t *testing.T) {
|
|
func TestSysRoleModel_BatchInsertWithTx_Rollback(t *testing.T) {
|
|
|
ctx := context.Background()
|
|
ctx := context.Background()
|
|
|
conn := testutil.GetTestSqlConn()
|
|
conn := testutil.GetTestSqlConn()
|
|
@@ -657,7 +657,7 @@ func TestSysRoleModel_BatchInsertWithTx_Rollback(t *testing.T) {
|
|
|
require.ErrorIs(t, err, ErrNotFound)
|
|
require.ErrorIs(t, err, ErrNotFound)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TC-0301: 正常多条
|
|
|
|
|
|
|
+// TC-0320: 正常多条
|
|
|
func TestSysRoleModel_BatchUpdateWithTx_Normal(t *testing.T) {
|
|
func TestSysRoleModel_BatchUpdateWithTx_Normal(t *testing.T) {
|
|
|
ctx := context.Background()
|
|
ctx := context.Background()
|
|
|
conn := testutil.GetTestSqlConn()
|
|
conn := testutil.GetTestSqlConn()
|
|
@@ -694,7 +694,7 @@ func TestSysRoleModel_BatchUpdateWithTx_Normal(t *testing.T) {
|
|
|
assert.Equal(t, "tx_new2", g2.Remark)
|
|
assert.Equal(t, "tx_new2", g2.Remark)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TC-0300: 空列表
|
|
|
|
|
|
|
+// TC-0319: 空列表
|
|
|
func TestSysRoleModel_BatchUpdateWithTx_Empty(t *testing.T) {
|
|
func TestSysRoleModel_BatchUpdateWithTx_Empty(t *testing.T) {
|
|
|
conn := testutil.GetTestSqlConn()
|
|
conn := testutil.GetTestSqlConn()
|
|
|
m := NewSysRoleModel(conn, testutil.GetTestCacheConf(), testutil.GetTestCachePrefix())
|
|
m := NewSysRoleModel(conn, testutil.GetTestCacheConf(), testutil.GetTestCachePrefix())
|
|
@@ -704,7 +704,7 @@ func TestSysRoleModel_BatchUpdateWithTx_Empty(t *testing.T) {
|
|
|
require.NoError(t, err)
|
|
require.NoError(t, err)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TC-0306: 单个id
|
|
|
|
|
|
|
+// TC-0325: 单个id
|
|
|
func TestSysRoleModel_BatchDelete_Single(t *testing.T) {
|
|
func TestSysRoleModel_BatchDelete_Single(t *testing.T) {
|
|
|
ctx := context.Background()
|
|
ctx := context.Background()
|
|
|
conn := testutil.GetTestSqlConn()
|
|
conn := testutil.GetTestSqlConn()
|
|
@@ -725,7 +725,7 @@ func TestSysRoleModel_BatchDelete_Single(t *testing.T) {
|
|
|
require.ErrorIs(t, err, ErrNotFound)
|
|
require.ErrorIs(t, err, ErrNotFound)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TC-0308: 包含不存在id
|
|
|
|
|
|
|
+// TC-0327: 包含不存在id
|
|
|
func TestSysRoleModel_BatchDelete_ContainsNonExist(t *testing.T) {
|
|
func TestSysRoleModel_BatchDelete_ContainsNonExist(t *testing.T) {
|
|
|
ctx := context.Background()
|
|
ctx := context.Background()
|
|
|
conn := testutil.GetTestSqlConn()
|
|
conn := testutil.GetTestSqlConn()
|
|
@@ -746,7 +746,7 @@ func TestSysRoleModel_BatchDelete_ContainsNonExist(t *testing.T) {
|
|
|
require.ErrorIs(t, err, ErrNotFound)
|
|
require.ErrorIs(t, err, ErrNotFound)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TC-0310: 正常多条
|
|
|
|
|
|
|
+// TC-0329: 正常多条
|
|
|
func TestSysRoleModel_BatchDeleteWithTx_Normal(t *testing.T) {
|
|
func TestSysRoleModel_BatchDeleteWithTx_Normal(t *testing.T) {
|
|
|
ctx := context.Background()
|
|
ctx := context.Background()
|
|
|
conn := testutil.GetTestSqlConn()
|
|
conn := testutil.GetTestSqlConn()
|
|
@@ -776,7 +776,7 @@ func TestSysRoleModel_BatchDeleteWithTx_Normal(t *testing.T) {
|
|
|
require.ErrorIs(t, err, ErrNotFound)
|
|
require.ErrorIs(t, err, ErrNotFound)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TC-0309: 空ids
|
|
|
|
|
|
|
+// TC-0328: 空ids
|
|
|
func TestSysRoleModel_BatchDeleteWithTx_Empty(t *testing.T) {
|
|
func TestSysRoleModel_BatchDeleteWithTx_Empty(t *testing.T) {
|
|
|
conn := testutil.GetTestSqlConn()
|
|
conn := testutil.GetTestSqlConn()
|
|
|
m := NewSysRoleModel(conn, testutil.GetTestCacheConf(), testutil.GetTestCachePrefix())
|
|
m := NewSysRoleModel(conn, testutil.GetTestCacheConf(), testutil.GetTestCachePrefix())
|
|
@@ -786,7 +786,7 @@ func TestSysRoleModel_BatchDeleteWithTx_Empty(t *testing.T) {
|
|
|
require.NoError(t, err)
|
|
require.NoError(t, err)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TC-0278: 事务内可见性
|
|
|
|
|
|
|
+// TC-0294: 事务内可见性
|
|
|
func TestSysRoleModel_FindOneWithTx_InsertThenFind(t *testing.T) {
|
|
func TestSysRoleModel_FindOneWithTx_InsertThenFind(t *testing.T) {
|
|
|
ctx := context.Background()
|
|
ctx := context.Background()
|
|
|
conn := testutil.GetTestSqlConn()
|
|
conn := testutil.GetTestSqlConn()
|
|
@@ -821,7 +821,7 @@ func TestSysRoleModel_FindOneWithTx_InsertThenFind(t *testing.T) {
|
|
|
t.Cleanup(func() { testutil.CleanTable(ctx, conn, tbl, insertedID) })
|
|
t.Cleanup(func() { testutil.CleanTable(ctx, conn, tbl, insertedID) })
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TC-0277: 事务内记录不存在
|
|
|
|
|
|
|
+// TC-0293: 事务内记录不存在
|
|
|
func TestSysRoleModel_FindOneWithTx_NotFound(t *testing.T) {
|
|
func TestSysRoleModel_FindOneWithTx_NotFound(t *testing.T) {
|
|
|
ctx := context.Background()
|
|
ctx := context.Background()
|
|
|
conn := testutil.GetTestSqlConn()
|
|
conn := testutil.GetTestSqlConn()
|
|
@@ -835,7 +835,7 @@ func TestSysRoleModel_FindOneWithTx_NotFound(t *testing.T) {
|
|
|
require.NoError(t, err)
|
|
require.NoError(t, err)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TC-0329: FindOneByProductCodeNameWithTx
|
|
|
|
|
|
|
+// TC-0348: FindOneByProductCodeNameWithTx
|
|
|
func TestSysRoleModel_FindOneByProductCodeNameWithTx_InsertThenFind(t *testing.T) {
|
|
func TestSysRoleModel_FindOneByProductCodeNameWithTx_InsertThenFind(t *testing.T) {
|
|
|
ctx := context.Background()
|
|
ctx := context.Background()
|
|
|
conn := testutil.GetTestSqlConn()
|
|
conn := testutil.GetTestSqlConn()
|
|
@@ -870,7 +870,7 @@ func TestSysRoleModel_FindOneByProductCodeNameWithTx_InsertThenFind(t *testing.T
|
|
|
t.Cleanup(func() { testutil.CleanTable(ctx, conn, tbl, insertedID) })
|
|
t.Cleanup(func() { testutil.CleanTable(ctx, conn, tbl, insertedID) })
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TC-0330: FindOneByProductCodeNameWithTx
|
|
|
|
|
|
|
+// TC-0349: FindOneByProductCodeNameWithTx
|
|
|
func TestSysRoleModel_FindOneByProductCodeNameWithTx_NotFound(t *testing.T) {
|
|
func TestSysRoleModel_FindOneByProductCodeNameWithTx_NotFound(t *testing.T) {
|
|
|
ctx := context.Background()
|
|
ctx := context.Background()
|
|
|
conn := testutil.GetTestSqlConn()
|
|
conn := testutil.GetTestSqlConn()
|
|
@@ -884,7 +884,7 @@ func TestSysRoleModel_FindOneByProductCodeNameWithTx_NotFound(t *testing.T) {
|
|
|
require.NoError(t, err)
|
|
require.NoError(t, err)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TC-0492: FindMinPermsLevelByUserIdAndProductCode 正常返回最小权限级别
|
|
|
|
|
|
|
+// TC-0422: FindMinPermsLevelByUserIdAndProductCode 正常返回最小权限级别
|
|
|
func TestSysRoleModel_FindMinPermsLevelByUserIdAndProductCode_Normal(t *testing.T) {
|
|
func TestSysRoleModel_FindMinPermsLevelByUserIdAndProductCode_Normal(t *testing.T) {
|
|
|
ctx := context.Background()
|
|
ctx := context.Background()
|
|
|
conn := testutil.GetTestSqlConn()
|
|
conn := testutil.GetTestSqlConn()
|
|
@@ -923,7 +923,7 @@ func TestSysRoleModel_FindMinPermsLevelByUserIdAndProductCode_Normal(t *testing.
|
|
|
assert.Equal(t, int64(5), level)
|
|
assert.Equal(t, int64(5), level)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TC-0493: FindMinPermsLevelByUserIdAndProductCode 无角色返回ErrNotFound
|
|
|
|
|
|
|
+// TC-0423: FindMinPermsLevelByUserIdAndProductCode 无角色返回ErrNotFound
|
|
|
func TestSysRoleModel_FindMinPermsLevelByUserIdAndProductCode_NoRoles(t *testing.T) {
|
|
func TestSysRoleModel_FindMinPermsLevelByUserIdAndProductCode_NoRoles(t *testing.T) {
|
|
|
conn := testutil.GetTestSqlConn()
|
|
conn := testutil.GetTestSqlConn()
|
|
|
m := NewSysRoleModel(conn, testutil.GetTestCacheConf(), testutil.GetTestCachePrefix())
|
|
m := NewSysRoleModel(conn, testutil.GetTestCacheConf(), testutil.GetTestCachePrefix())
|
|
@@ -933,7 +933,7 @@ func TestSysRoleModel_FindMinPermsLevelByUserIdAndProductCode_NoRoles(t *testing
|
|
|
require.ErrorIs(t, err, ErrNotFound)
|
|
require.ErrorIs(t, err, ErrNotFound)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TC-0302: buildBatchUpdateQuery 单条
|
|
|
|
|
|
|
+// TC-0321: buildBatchUpdateQuery 单条
|
|
|
func TestSysRoleModel_buildBatchUpdateQuery_Single(t *testing.T) {
|
|
func TestSysRoleModel_buildBatchUpdateQuery_Single(t *testing.T) {
|
|
|
conn := testutil.GetTestSqlConn()
|
|
conn := testutil.GetTestSqlConn()
|
|
|
dm := newSysRoleModel(conn, testutil.GetTestCacheConf(), testutil.GetTestCachePrefix())
|
|
dm := newSysRoleModel(conn, testutil.GetTestCacheConf(), testutil.GetTestCachePrefix())
|
|
@@ -951,7 +951,7 @@ func TestSysRoleModel_buildBatchUpdateQuery_Single(t *testing.T) {
|
|
|
assert.Equal(t, 15, len(vals))
|
|
assert.Equal(t, 15, len(vals))
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TC-0303: buildBatchUpdateQuery 多条
|
|
|
|
|
|
|
+// TC-0322: buildBatchUpdateQuery 多条
|
|
|
func TestSysRoleModel_buildBatchUpdateQuery_Multi(t *testing.T) {
|
|
func TestSysRoleModel_buildBatchUpdateQuery_Multi(t *testing.T) {
|
|
|
conn := testutil.GetTestSqlConn()
|
|
conn := testutil.GetTestSqlConn()
|
|
|
dm := newSysRoleModel(conn, testutil.GetTestCacheConf(), testutil.GetTestCachePrefix())
|
|
dm := newSysRoleModel(conn, testutil.GetTestCacheConf(), testutil.GetTestCachePrefix())
|
|
@@ -969,7 +969,7 @@ func TestSysRoleModel_buildBatchUpdateQuery_Multi(t *testing.T) {
|
|
|
assert.Equal(t, 45, len(vals))
|
|
assert.Equal(t, 45, len(vals))
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TC-0304: buildBatchUpdateQuery vals数量正确
|
|
|
|
|
|
|
+// TC-0323: buildBatchUpdateQuery vals数量正确
|
|
|
func TestSysRoleModel_buildBatchUpdateQuery_ValsCount(t *testing.T) {
|
|
func TestSysRoleModel_buildBatchUpdateQuery_ValsCount(t *testing.T) {
|
|
|
conn := testutil.GetTestSqlConn()
|
|
conn := testutil.GetTestSqlConn()
|
|
|
dm := newSysRoleModel(conn, testutil.GetTestCacheConf(), testutil.GetTestCachePrefix())
|
|
dm := newSysRoleModel(conn, testutil.GetTestCacheConf(), testutil.GetTestCachePrefix())
|
|
@@ -989,7 +989,7 @@ func TestSysRoleModel_buildBatchUpdateQuery_ValsCount(t *testing.T) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TC-0347: findListByPrimaryKeys 空ids
|
|
|
|
|
|
|
+// TC-0366: findListByPrimaryKeys 空ids
|
|
|
func TestSysRoleModel_findListByPrimaryKeys_Empty(t *testing.T) {
|
|
func TestSysRoleModel_findListByPrimaryKeys_Empty(t *testing.T) {
|
|
|
conn := testutil.GetTestSqlConn()
|
|
conn := testutil.GetTestSqlConn()
|
|
|
dm := newSysRoleModel(conn, testutil.GetTestCacheConf(), testutil.GetTestCachePrefix())
|
|
dm := newSysRoleModel(conn, testutil.GetTestCacheConf(), testutil.GetTestCachePrefix())
|
|
@@ -999,7 +999,7 @@ func TestSysRoleModel_findListByPrimaryKeys_Empty(t *testing.T) {
|
|
|
require.Empty(t, list)
|
|
require.Empty(t, list)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TC-0348: findListByPrimaryKeys 正常ids
|
|
|
|
|
|
|
+// TC-0367: findListByPrimaryKeys 正常ids
|
|
|
func TestSysRoleModel_findListByPrimaryKeys_Normal(t *testing.T) {
|
|
func TestSysRoleModel_findListByPrimaryKeys_Normal(t *testing.T) {
|
|
|
ctx := context.Background()
|
|
ctx := context.Background()
|
|
|
conn := testutil.GetTestSqlConn()
|
|
conn := testutil.GetTestSqlConn()
|
|
@@ -1021,7 +1021,7 @@ func TestSysRoleModel_findListByPrimaryKeys_Normal(t *testing.T) {
|
|
|
require.Len(t, list, 2)
|
|
require.Len(t, list, 2)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TC-0349: findListByPrimaryKeys 部分不存在
|
|
|
|
|
|
|
+// TC-0368: findListByPrimaryKeys 部分不存在
|
|
|
func TestSysRoleModel_findListByPrimaryKeys_PartialNotExist(t *testing.T) {
|
|
func TestSysRoleModel_findListByPrimaryKeys_PartialNotExist(t *testing.T) {
|
|
|
ctx := context.Background()
|
|
ctx := context.Background()
|
|
|
conn := testutil.GetTestSqlConn()
|
|
conn := testutil.GetTestSqlConn()
|
|
@@ -1041,7 +1041,7 @@ func TestSysRoleModel_findListByPrimaryKeys_PartialNotExist(t *testing.T) {
|
|
|
assert.Equal(t, id, list[0].Id)
|
|
assert.Equal(t, id, list[0].Id)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TC-0350: findListByPrimaryKeys DB异常
|
|
|
|
|
|
|
+// TC-0369: findListByPrimaryKeys DB异常
|
|
|
func TestSysRoleModel_findListByPrimaryKeys_DBError(t *testing.T) {
|
|
func TestSysRoleModel_findListByPrimaryKeys_DBError(t *testing.T) {
|
|
|
badConn := sqlx.NewMysql("root:bad@tcp(127.0.0.1:1)/nodb")
|
|
badConn := sqlx.NewMysql("root:bad@tcp(127.0.0.1:1)/nodb")
|
|
|
dm := newSysRoleModel(badConn, testutil.GetTestCacheConf(), testutil.GetTestCachePrefix())
|
|
dm := newSysRoleModel(badConn, testutil.GetTestCacheConf(), testutil.GetTestCachePrefix())
|
|
@@ -1050,7 +1050,7 @@ func TestSysRoleModel_findListByPrimaryKeys_DBError(t *testing.T) {
|
|
|
require.Error(t, err)
|
|
require.Error(t, err)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TC-0351: getPrimaryKeyValue 正常
|
|
|
|
|
|
|
+// TC-0370: getPrimaryKeyValue 正常
|
|
|
func TestSysRoleModel_getPrimaryKeyValue_Normal(t *testing.T) {
|
|
func TestSysRoleModel_getPrimaryKeyValue_Normal(t *testing.T) {
|
|
|
conn := testutil.GetTestSqlConn()
|
|
conn := testutil.GetTestSqlConn()
|
|
|
dm := newSysRoleModel(conn, testutil.GetTestCacheConf(), testutil.GetTestCachePrefix())
|
|
dm := newSysRoleModel(conn, testutil.GetTestCacheConf(), testutil.GetTestCachePrefix())
|
|
@@ -1060,7 +1060,7 @@ func TestSysRoleModel_getPrimaryKeyValue_Normal(t *testing.T) {
|
|
|
assert.Equal(t, int64(42), val)
|
|
assert.Equal(t, int64(42), val)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TC-0352: formatPrimary 正常
|
|
|
|
|
|
|
+// TC-0371: formatPrimary 正常
|
|
|
func TestSysRoleModel_formatPrimary_Normal(t *testing.T) {
|
|
func TestSysRoleModel_formatPrimary_Normal(t *testing.T) {
|
|
|
conn := testutil.GetTestSqlConn()
|
|
conn := testutil.GetTestSqlConn()
|
|
|
dm := newSysRoleModel(conn, testutil.GetTestCacheConf(), testutil.GetTestCachePrefix())
|
|
dm := newSysRoleModel(conn, testutil.GetTestCacheConf(), testutil.GetTestCachePrefix())
|
|
@@ -1070,7 +1070,7 @@ func TestSysRoleModel_formatPrimary_Normal(t *testing.T) {
|
|
|
assert.Contains(t, key, "123")
|
|
assert.Contains(t, key, "123")
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TC-0353: queryPrimary 正常
|
|
|
|
|
|
|
+// TC-0372: queryPrimary 正常
|
|
|
func TestSysRoleModel_queryPrimary_Normal(t *testing.T) {
|
|
func TestSysRoleModel_queryPrimary_Normal(t *testing.T) {
|
|
|
ctx := context.Background()
|
|
ctx := context.Background()
|
|
|
conn := testutil.GetTestSqlConn()
|
|
conn := testutil.GetTestSqlConn()
|
|
@@ -1093,7 +1093,7 @@ func TestSysRoleModel_queryPrimary_Normal(t *testing.T) {
|
|
|
assert.Equal(t, name, result.Name)
|
|
assert.Equal(t, name, result.Name)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TC-0354: cachePrefix为空
|
|
|
|
|
|
|
+// TC-0373: cachePrefix为空
|
|
|
func TestSysRoleModel_CachePrefix_Empty(t *testing.T) {
|
|
func TestSysRoleModel_CachePrefix_Empty(t *testing.T) {
|
|
|
oldId := cacheSysRoleIdPrefix
|
|
oldId := cacheSysRoleIdPrefix
|
|
|
oldName := cacheSysRoleProductCodeNamePrefix
|
|
oldName := cacheSysRoleProductCodeNamePrefix
|
|
@@ -1110,7 +1110,7 @@ func TestSysRoleModel_CachePrefix_Empty(t *testing.T) {
|
|
|
assert.Equal(t, "cache:sysRole:id:123", key)
|
|
assert.Equal(t, "cache:sysRole:id:123", key)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TC-0355: cachePrefix非空
|
|
|
|
|
|
|
+// TC-0374: cachePrefix非空
|
|
|
func TestSysRoleModel_CachePrefix_NonEmpty(t *testing.T) {
|
|
func TestSysRoleModel_CachePrefix_NonEmpty(t *testing.T) {
|
|
|
oldId := cacheSysRoleIdPrefix
|
|
oldId := cacheSysRoleIdPrefix
|
|
|
oldName := cacheSysRoleProductCodeNamePrefix
|
|
oldName := cacheSysRoleProductCodeNamePrefix
|
|
@@ -1125,7 +1125,7 @@ func TestSysRoleModel_CachePrefix_NonEmpty(t *testing.T) {
|
|
|
assert.True(t, strings.HasPrefix(key, "test:"))
|
|
assert.True(t, strings.HasPrefix(key, "test:"))
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TC-0372: FindListByProductCode count查询失败(DB异常)
|
|
|
|
|
|
|
+// TC-0393: FindListByProductCode count查询失败(DB异常)
|
|
|
func TestSysRoleModel_FindListByProductCode_DBError(t *testing.T) {
|
|
func TestSysRoleModel_FindListByProductCode_DBError(t *testing.T) {
|
|
|
badConn := sqlx.NewMysql("root:bad@tcp(127.0.0.1:1)/bad?timeout=1s")
|
|
badConn := sqlx.NewMysql("root:bad@tcp(127.0.0.1:1)/bad?timeout=1s")
|
|
|
m := NewSysRoleModel(badConn, testutil.GetTestCacheConf(), testutil.GetTestCachePrefix())
|
|
m := NewSysRoleModel(badConn, testutil.GetTestCacheConf(), testutil.GetTestCachePrefix())
|