feat: 迁移商务旗下渠道查询和抽屉
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package business
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
)
|
||||
|
||||
type directPromoteRepoFake struct{ calls int }
|
||||
|
||||
func (r *directPromoteRepoFake) ListDirect(context.Context, BusinessPromoteFilter, ...ListOption) (*BusinessPromotePage, error) {
|
||||
r.calls++
|
||||
return &BusinessPromotePage{Available: true}, nil
|
||||
}
|
||||
func TestDirectPromotesCheckUserScopeBeforeReadingChannels(t *testing.T) {
|
||||
a := &accountRepoFake{accounts: map[uint]*Account{12: {ID: 12, Level: 1, IDPath: "0"}, 13: {ID: 13, Level: 2, IDPath: "0,12"}, 99: {ID: 99, Level: 2, IDPath: "0,123"}}}
|
||||
r := &directPromoteRepoFake{}
|
||||
uc := NewBusinessPromoteUsecase(r, NewAccountUsecase(a))
|
||||
if _, err := uc.List(accountContext(12, 901), BusinessPromoteFilter{UserID: 99}); err != ErrAccountScope || r.calls != 0 {
|
||||
t.Fatal("越权请求触达了渠道仓储")
|
||||
}
|
||||
if _, err := uc.List(accountContext(12, 901), BusinessPromoteFilter{UserID: 13}); err != nil || r.calls != 1 {
|
||||
t.Fatal("下级渠道查询未执行")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user