chore(init): 初始化解忧商行项目并完成 Phase 0 基座

This commit is contained in:
yml2213
2026-10-30 11:46:10 +08:00
commit 8d9481c251
689 changed files with 138703 additions and 0 deletions
@@ -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)
}
}