优化结构
This commit is contained in:
@@ -2,9 +2,8 @@ package system
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kra/internal/biz/system"
|
||||
"testing"
|
||||
|
||||
"kra/internal/biz"
|
||||
)
|
||||
|
||||
func TestDictionaryListPreservesPreloadCollectionShapes(t *testing.T) {
|
||||
@@ -12,10 +11,10 @@ func TestDictionaryListPreservesPreloadCollectionShapes(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
repo := &dictionaryRepo{data: data}
|
||||
|
||||
if err := repo.CreateDictionary(ctx, &biz.Dictionary{Name: "status", Type: "status"}); err != nil {
|
||||
if err := repo.CreateDictionary(ctx, &system.Dictionary{Name: "status", Type: "status"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := repo.CreateDictionary(ctx, &biz.Dictionary{Name: "kind", Type: "kind"}); err != nil {
|
||||
if err := repo.CreateDictionary(ctx, &system.Dictionary{Name: "kind", Type: "kind"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -47,10 +46,10 @@ func TestImportDictionaryRejectsDuplicateType(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
repo := &dictionaryRepo{data: data}
|
||||
|
||||
if err := repo.CreateDictionary(ctx, &biz.Dictionary{Name: "first", Type: "duplicate"}); err != nil {
|
||||
if err := repo.CreateDictionary(ctx, &system.Dictionary{Name: "first", Type: "duplicate"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := repo.ImportDictionary(ctx, &biz.Dictionary{Name: "second", Type: "duplicate"}, nil); err == nil || err.Error() != "存在相同的type,不允许导入" {
|
||||
if err := repo.ImportDictionary(ctx, &system.Dictionary{Name: "second", Type: "duplicate"}, nil); err == nil || err.Error() != "存在相同的type,不允许导入" {
|
||||
t.Fatalf("duplicate import error = %v", err)
|
||||
}
|
||||
|
||||
@@ -68,16 +67,16 @@ func TestDictionaryTreeAndParentQueriesPreserveLoadedChildrenShape(t *testing.T)
|
||||
ctx := context.Background()
|
||||
repo := &dictionaryRepo{data: data}
|
||||
|
||||
dictionary := &biz.Dictionary{Name: "tree", Type: "tree"}
|
||||
dictionary := &system.Dictionary{Name: "tree", Type: "tree"}
|
||||
if err := repo.CreateDictionary(ctx, dictionary); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
parent := &biz.DictionaryDetail{Label: "parent", Value: "parent", DictionaryID: dictionary.ID, Sort: 2}
|
||||
parent := &system.DictionaryDetail{Label: "parent", Value: "parent", DictionaryID: dictionary.ID, Sort: 2}
|
||||
if err := repo.CreateDictionaryDetail(ctx, parent); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
parentID := parent.ID
|
||||
child := &biz.DictionaryDetail{Label: "child", Value: "child", DictionaryID: dictionary.ID, ParentID: &parentID, Sort: 1}
|
||||
child := &system.DictionaryDetail{Label: "child", Value: "child", DictionaryID: dictionary.ID, ParentID: &parentID, Sort: 1}
|
||||
if err := repo.CreateDictionaryDetail(ctx, child); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -112,15 +111,15 @@ func TestDictionaryDetailListAppliesZeroLimit(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
repo := &dictionaryRepo{data: data}
|
||||
|
||||
dictionary := &biz.Dictionary{Name: "limited", Type: "limited"}
|
||||
dictionary := &system.Dictionary{Name: "limited", Type: "limited"}
|
||||
if err := repo.CreateDictionary(ctx, dictionary); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := repo.CreateDictionaryDetail(ctx, &biz.DictionaryDetail{Label: "one", Value: "one", DictionaryID: dictionary.ID}); err != nil {
|
||||
if err := repo.CreateDictionaryDetail(ctx, &system.DictionaryDetail{Label: "one", Value: "one", DictionaryID: dictionary.ID}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
items, total, err := repo.ListDictionaryDetails(ctx, 0, 0, biz.DictionaryDetailFilter{DictionaryID: dictionary.ID})
|
||||
items, total, err := repo.ListDictionaryDetails(ctx, 0, 0, system.DictionaryDetailFilter{DictionaryID: dictionary.ID})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -136,7 +135,7 @@ func TestUserListAppliesZeroLimitForNegativePageSize(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
items, total, err := (&userRepo{data: data}).ListUsers(ctx, 1, -1, &biz.UserListFilter{})
|
||||
items, total, err := (&userRepo{data: data}).ListUsers(ctx, 1, -1, &system.UserListFilter{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -150,7 +149,7 @@ func TestDepartmentTreeAndFlatResultsPreserveChildrenShape(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
repo := &departmentRepo{data: data}
|
||||
|
||||
root := &biz.Department{Name: "root"}
|
||||
root := &system.Department{Name: "root"}
|
||||
if err := repo.CreateDepartment(ctx, root); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -158,7 +157,7 @@ func TestDepartmentTreeAndFlatResultsPreserveChildrenShape(t *testing.T) {
|
||||
if err := data.gormDB.WithContext(ctx).Where("name = ?", "root").First(&rootPO).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := repo.CreateDepartment(ctx, &biz.Department{Name: "child", ParentID: rootPO.ID}); err != nil {
|
||||
if err := repo.CreateDepartment(ctx, &system.Department{Name: "child", ParentID: rootPO.ID}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user