chore(init): 初始化解忧商行项目并完成 Phase 0 基座
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
package wallet
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestServiceAccountWithNilRepo 测试依赖检查
|
||||
func TestServiceAccountWithNilRepo(t *testing.T) {
|
||||
svc := &Service{repo: nil}
|
||||
ctx := context.Background()
|
||||
_, err := svc.Account(ctx, 1)
|
||||
if !errors.Is(err, ErrDependencyUnavailable) {
|
||||
t.Fatalf("Account() error = %v, want ErrDependencyUnavailable", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestServiceLedgerWithNilRepo(t *testing.T) {
|
||||
svc := &Service{repo: nil}
|
||||
ctx := context.Background()
|
||||
_, err := svc.Ledger(ctx, 1, 1, 10)
|
||||
if !errors.Is(err, ErrDependencyUnavailable) {
|
||||
t.Fatalf("Ledger() error = %v, want ErrDependencyUnavailable", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestServiceWithdrawIsPending(t *testing.T) {
|
||||
svc := &Service{repo: &Repository{}}
|
||||
ctx := context.Background()
|
||||
_, err := svc.Withdraw(ctx, 1, WithdrawRequest{AmountCent: 100})
|
||||
if !errors.Is(err, ErrFeaturePending) {
|
||||
t.Fatalf("Withdraw() error = %v, want ErrFeaturePending", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestServiceAdminLedgerWithNilRepo(t *testing.T) {
|
||||
svc := &Service{repo: nil}
|
||||
ctx := context.Background()
|
||||
_, err := svc.AdminLedger(ctx, AdminLedgerQuery{Page: 1, PageSize: 10})
|
||||
if !errors.Is(err, ErrDependencyUnavailable) {
|
||||
t.Fatalf("AdminLedger() error = %v, want ErrDependencyUnavailable", err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user