完善配送端资源搜索与资质导航
This commit is contained in:
@@ -31,3 +31,24 @@ func TestDeliveryStaffQueryKeepsRoleScope(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestScopedCredentialQueryKeepsOwnerAndRoleScope 验证资质列表同时限制人员和配送角色。
|
||||
func TestScopedCredentialQueryKeepsOwnerAndRoleScope(t *testing.T) {
|
||||
connection, _, err := sqlmock.New()
|
||||
if err != nil {
|
||||
t.Fatalf("创建 SQL mock 失败:%v", err)
|
||||
}
|
||||
t.Cleanup(func() { _ = connection.Close() })
|
||||
databaseService, err := gorm.Open(postgres.New(postgres.Config{Conn: connection}), &gorm.Config{DryRun: true})
|
||||
if err != nil {
|
||||
t.Fatalf("打开 GORM 失败:%v", err)
|
||||
}
|
||||
point := models.DeliveryBasic{Entity: models.Entity{ID: 22}, GasBasicID: 11}
|
||||
statement := scopedCredentialQuery(databaseService, point, 33).
|
||||
Find(&[]models.StaffCredential{}).Statement.SQL.String()
|
||||
for _, required := range []string{"delivery_basic_id", "gas_basic_id", "role_code", "staff_account_id"} {
|
||||
if !strings.Contains(statement, required) {
|
||||
t.Fatalf("配送人员资质范围缺少 %s:%s", required, statement)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user