Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
陈曦
sub2api
Commits
c27d5117
Commit
c27d5117
authored
Jan 05, 2026
by
longgexx
Committed by
long
Jan 05, 2026
Browse files
test(billing): 更新测试用例以验证透支策略
parent
d6f8ac02
Changes
1
Hide whitespace changes
Inline
Side-by-side
backend/internal/repository/user_repo_integration_test.go
View file @
c27d5117
...
...
@@ -495,9 +495,12 @@ func (s *UserRepoSuite) TestCRUD_And_Filters_And_AtomicUpdates() {
s
.
Require
()
.
NoError
(
err
,
"GetByID after DeductBalance"
)
s
.
Require
()
.
InDelta
(
7.5
,
got4
.
Balance
,
1e-6
)
// 透支策略:允许扣除超过余额的金额
err
=
s
.
repo
.
DeductBalance
(
s
.
ctx
,
user1
.
ID
,
999
)
s
.
Require
()
.
Error
(
err
,
"DeductBalance expected error for insufficient balance"
)
s
.
Require
()
.
ErrorIs
(
err
,
service
.
ErrInsufficientBalance
,
"DeductBalance unexpected error"
)
s
.
Require
()
.
NoError
(
err
,
"DeductBalance should allow overdraft"
)
gotOverdraft
,
err
:=
s
.
repo
.
GetByID
(
s
.
ctx
,
user1
.
ID
)
s
.
Require
()
.
NoError
(
err
,
"GetByID after overdraft"
)
s
.
Require
()
.
Less
(
gotOverdraft
.
Balance
,
0.0
,
"Balance should be negative after overdraft"
)
s
.
Require
()
.
NoError
(
s
.
repo
.
UpdateConcurrency
(
s
.
ctx
,
user1
.
ID
,
3
),
"UpdateConcurrency"
)
got5
,
err
:=
s
.
repo
.
GetByID
(
s
.
ctx
,
user1
.
ID
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment