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
fa28dcbf
Commit
fa28dcbf
authored
Feb 07, 2026
by
erio
Browse files
fix(test): update test calls to match method receivers on handleSmartRetry and antigravityRetryLoop
parent
2656320d
Changes
2
Show whitespace changes
Inline
Side-by-side
backend/internal/service/antigravity_rate_limit_test.go
View file @
fa28dcbf
...
@@ -122,7 +122,8 @@ func TestAntigravityRetryLoop_URLFallback_UsesLatestSuccess(t *testing.T) {
...
@@ -122,7 +122,8 @@ func TestAntigravityRetryLoop_URLFallback_UsesLatestSuccess(t *testing.T) {
}
}
var
handleErrorCalled
bool
var
handleErrorCalled
bool
result
,
err
:=
antigravityRetryLoop
(
antigravityRetryLoopParams
{
svc
:=
&
AntigravityGatewayService
{}
result
,
err
:=
svc
.
antigravityRetryLoop
(
antigravityRetryLoopParams
{
prefix
:
"[test]"
,
prefix
:
"[test]"
,
ctx
:
context
.
Background
(),
ctx
:
context
.
Background
(),
account
:
account
,
account
:
account
,
...
@@ -824,7 +825,8 @@ func TestAntigravityRetryLoop_PreCheck_WaitsWhenRemainingBelowThreshold(t *testi
...
@@ -824,7 +825,8 @@ func TestAntigravityRetryLoop_PreCheck_WaitsWhenRemainingBelowThreshold(t *testi
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
30
*
time
.
Millisecond
)
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
30
*
time
.
Millisecond
)
defer
cancel
()
defer
cancel
()
result
,
err
:=
antigravityRetryLoop
(
antigravityRetryLoopParams
{
svc
:=
&
AntigravityGatewayService
{}
result
,
err
:=
svc
.
antigravityRetryLoop
(
antigravityRetryLoopParams
{
ctx
:
ctx
,
ctx
:
ctx
,
prefix
:
"[test]"
,
prefix
:
"[test]"
,
account
:
account
,
account
:
account
,
...
@@ -862,7 +864,8 @@ func TestAntigravityRetryLoop_PreCheck_SwitchesWhenRemainingAtOrAboveThreshold(t
...
@@ -862,7 +864,8 @@ func TestAntigravityRetryLoop_PreCheck_SwitchesWhenRemainingAtOrAboveThreshold(t
},
},
}
}
result
,
err
:=
antigravityRetryLoop
(
antigravityRetryLoopParams
{
svc
:=
&
AntigravityGatewayService
{}
result
,
err
:=
svc
.
antigravityRetryLoop
(
antigravityRetryLoopParams
{
ctx
:
context
.
Background
(),
ctx
:
context
.
Background
(),
prefix
:
"[test]"
,
prefix
:
"[test]"
,
account
:
account
,
account
:
account
,
...
...
backend/internal/service/antigravity_smart_retry_test.go
View file @
fa28dcbf
...
@@ -65,7 +65,8 @@ func TestHandleSmartRetry_URLLevelRateLimit(t *testing.T) {
...
@@ -65,7 +65,8 @@ func TestHandleSmartRetry_URLLevelRateLimit(t *testing.T) {
availableURLs
:=
[]
string
{
"https://ag-1.test"
,
"https://ag-2.test"
}
availableURLs
:=
[]
string
{
"https://ag-1.test"
,
"https://ag-2.test"
}
result
:=
handleSmartRetry
(
params
,
resp
,
respBody
,
"https://ag-1.test"
,
0
,
availableURLs
)
svc
:=
&
AntigravityGatewayService
{}
result
:=
svc
.
handleSmartRetry
(
params
,
resp
,
respBody
,
"https://ag-1.test"
,
0
,
availableURLs
)
require
.
NotNil
(
t
,
result
)
require
.
NotNil
(
t
,
result
)
require
.
Equal
(
t
,
smartRetryActionContinueURL
,
result
.
action
)
require
.
Equal
(
t
,
smartRetryActionContinueURL
,
result
.
action
)
...
@@ -116,7 +117,8 @@ func TestHandleSmartRetry_LongDelay_ReturnsSwitchError(t *testing.T) {
...
@@ -116,7 +117,8 @@ func TestHandleSmartRetry_LongDelay_ReturnsSwitchError(t *testing.T) {
availableURLs
:=
[]
string
{
"https://ag-1.test"
}
availableURLs
:=
[]
string
{
"https://ag-1.test"
}
result
:=
handleSmartRetry
(
params
,
resp
,
respBody
,
"https://ag-1.test"
,
0
,
availableURLs
)
svc
:=
&
AntigravityGatewayService
{}
result
:=
svc
.
handleSmartRetry
(
params
,
resp
,
respBody
,
"https://ag-1.test"
,
0
,
availableURLs
)
require
.
NotNil
(
t
,
result
)
require
.
NotNil
(
t
,
result
)
require
.
Equal
(
t
,
smartRetryActionBreakWithResp
,
result
.
action
)
require
.
Equal
(
t
,
smartRetryActionBreakWithResp
,
result
.
action
)
...
@@ -182,7 +184,8 @@ func TestHandleSmartRetry_ShortDelay_SmartRetrySuccess(t *testing.T) {
...
@@ -182,7 +184,8 @@ func TestHandleSmartRetry_ShortDelay_SmartRetrySuccess(t *testing.T) {
availableURLs
:=
[]
string
{
"https://ag-1.test"
}
availableURLs
:=
[]
string
{
"https://ag-1.test"
}
result
:=
handleSmartRetry
(
params
,
resp
,
respBody
,
"https://ag-1.test"
,
0
,
availableURLs
)
svc
:=
&
AntigravityGatewayService
{}
result
:=
svc
.
handleSmartRetry
(
params
,
resp
,
respBody
,
"https://ag-1.test"
,
0
,
availableURLs
)
require
.
NotNil
(
t
,
result
)
require
.
NotNil
(
t
,
result
)
require
.
Equal
(
t
,
smartRetryActionBreakWithResp
,
result
.
action
)
require
.
Equal
(
t
,
smartRetryActionBreakWithResp
,
result
.
action
)
...
@@ -266,7 +269,8 @@ func TestHandleSmartRetry_ShortDelay_SmartRetryFailed_ReturnsSwitchError(t *test
...
@@ -266,7 +269,8 @@ func TestHandleSmartRetry_ShortDelay_SmartRetryFailed_ReturnsSwitchError(t *test
availableURLs
:=
[]
string
{
"https://ag-1.test"
}
availableURLs
:=
[]
string
{
"https://ag-1.test"
}
result
:=
handleSmartRetry
(
params
,
resp
,
respBody
,
"https://ag-1.test"
,
0
,
availableURLs
)
svc
:=
&
AntigravityGatewayService
{}
result
:=
svc
.
handleSmartRetry
(
params
,
resp
,
respBody
,
"https://ag-1.test"
,
0
,
availableURLs
)
require
.
NotNil
(
t
,
result
)
require
.
NotNil
(
t
,
result
)
require
.
Equal
(
t
,
smartRetryActionBreakWithResp
,
result
.
action
)
require
.
Equal
(
t
,
smartRetryActionBreakWithResp
,
result
.
action
)
...
@@ -327,7 +331,8 @@ func TestHandleSmartRetry_503_ModelCapacityExhausted_ReturnsSwitchError(t *testi
...
@@ -327,7 +331,8 @@ func TestHandleSmartRetry_503_ModelCapacityExhausted_ReturnsSwitchError(t *testi
availableURLs
:=
[]
string
{
"https://ag-1.test"
}
availableURLs
:=
[]
string
{
"https://ag-1.test"
}
result
:=
handleSmartRetry
(
params
,
resp
,
respBody
,
"https://ag-1.test"
,
0
,
availableURLs
)
svc
:=
&
AntigravityGatewayService
{}
result
:=
svc
.
handleSmartRetry
(
params
,
resp
,
respBody
,
"https://ag-1.test"
,
0
,
availableURLs
)
require
.
NotNil
(
t
,
result
)
require
.
NotNil
(
t
,
result
)
require
.
Equal
(
t
,
smartRetryActionBreakWithResp
,
result
.
action
)
require
.
Equal
(
t
,
smartRetryActionBreakWithResp
,
result
.
action
)
...
@@ -382,7 +387,8 @@ func TestHandleSmartRetry_NonAntigravityAccount_ContinuesDefaultLogic(t *testing
...
@@ -382,7 +387,8 @@ func TestHandleSmartRetry_NonAntigravityAccount_ContinuesDefaultLogic(t *testing
availableURLs
:=
[]
string
{
"https://ag-1.test"
}
availableURLs
:=
[]
string
{
"https://ag-1.test"
}
result
:=
handleSmartRetry
(
params
,
resp
,
respBody
,
"https://ag-1.test"
,
0
,
availableURLs
)
svc
:=
&
AntigravityGatewayService
{}
result
:=
svc
.
handleSmartRetry
(
params
,
resp
,
respBody
,
"https://ag-1.test"
,
0
,
availableURLs
)
require
.
NotNil
(
t
,
result
)
require
.
NotNil
(
t
,
result
)
require
.
Equal
(
t
,
smartRetryActionContinue
,
result
.
action
,
"non-Antigravity platform account should continue default logic"
)
require
.
Equal
(
t
,
smartRetryActionContinue
,
result
.
action
,
"non-Antigravity platform account should continue default logic"
)
...
@@ -430,7 +436,8 @@ func TestHandleSmartRetry_NonModelRateLimit_ContinuesDefaultLogic(t *testing.T)
...
@@ -430,7 +436,8 @@ func TestHandleSmartRetry_NonModelRateLimit_ContinuesDefaultLogic(t *testing.T)
availableURLs
:=
[]
string
{
"https://ag-1.test"
}
availableURLs
:=
[]
string
{
"https://ag-1.test"
}
result
:=
handleSmartRetry
(
params
,
resp
,
respBody
,
"https://ag-1.test"
,
0
,
availableURLs
)
svc
:=
&
AntigravityGatewayService
{}
result
:=
svc
.
handleSmartRetry
(
params
,
resp
,
respBody
,
"https://ag-1.test"
,
0
,
availableURLs
)
require
.
NotNil
(
t
,
result
)
require
.
NotNil
(
t
,
result
)
require
.
Equal
(
t
,
smartRetryActionContinue
,
result
.
action
,
"non-model rate limit should continue default logic"
)
require
.
Equal
(
t
,
smartRetryActionContinue
,
result
.
action
,
"non-model rate limit should continue default logic"
)
...
@@ -480,7 +487,8 @@ func TestHandleSmartRetry_ExactlyAtThreshold_ReturnsSwitchError(t *testing.T) {
...
@@ -480,7 +487,8 @@ func TestHandleSmartRetry_ExactlyAtThreshold_ReturnsSwitchError(t *testing.T) {
availableURLs
:=
[]
string
{
"https://ag-1.test"
}
availableURLs
:=
[]
string
{
"https://ag-1.test"
}
result
:=
handleSmartRetry
(
params
,
resp
,
respBody
,
"https://ag-1.test"
,
0
,
availableURLs
)
svc
:=
&
AntigravityGatewayService
{}
result
:=
svc
.
handleSmartRetry
(
params
,
resp
,
respBody
,
"https://ag-1.test"
,
0
,
availableURLs
)
require
.
NotNil
(
t
,
result
)
require
.
NotNil
(
t
,
result
)
require
.
Equal
(
t
,
smartRetryActionBreakWithResp
,
result
.
action
)
require
.
Equal
(
t
,
smartRetryActionBreakWithResp
,
result
.
action
)
...
@@ -522,7 +530,8 @@ func TestAntigravityRetryLoop_HandleSmartRetry_SwitchError_Propagates(t *testing
...
@@ -522,7 +530,8 @@ func TestAntigravityRetryLoop_HandleSmartRetry_SwitchError_Propagates(t *testing
Concurrency
:
1
,
Concurrency
:
1
,
}
}
result
,
err
:=
antigravityRetryLoop
(
antigravityRetryLoopParams
{
svc
:=
&
AntigravityGatewayService
{}
result
,
err
:=
svc
.
antigravityRetryLoop
(
antigravityRetryLoopParams
{
ctx
:
context
.
Background
(),
ctx
:
context
.
Background
(),
prefix
:
"[test]"
,
prefix
:
"[test]"
,
account
:
account
,
account
:
account
,
...
@@ -598,7 +607,8 @@ func TestHandleSmartRetry_NetworkError_ContinuesRetry(t *testing.T) {
...
@@ -598,7 +607,8 @@ func TestHandleSmartRetry_NetworkError_ContinuesRetry(t *testing.T) {
availableURLs
:=
[]
string
{
"https://ag-1.test"
}
availableURLs
:=
[]
string
{
"https://ag-1.test"
}
result
:=
handleSmartRetry
(
params
,
resp
,
respBody
,
"https://ag-1.test"
,
0
,
availableURLs
)
svc
:=
&
AntigravityGatewayService
{}
result
:=
svc
.
handleSmartRetry
(
params
,
resp
,
respBody
,
"https://ag-1.test"
,
0
,
availableURLs
)
require
.
NotNil
(
t
,
result
)
require
.
NotNil
(
t
,
result
)
require
.
Equal
(
t
,
smartRetryActionBreakWithResp
,
result
.
action
)
require
.
Equal
(
t
,
smartRetryActionBreakWithResp
,
result
.
action
)
...
@@ -650,7 +660,8 @@ func TestHandleSmartRetry_NoRetryDelay_UsesDefaultRateLimit(t *testing.T) {
...
@@ -650,7 +660,8 @@ func TestHandleSmartRetry_NoRetryDelay_UsesDefaultRateLimit(t *testing.T) {
availableURLs
:=
[]
string
{
"https://ag-1.test"
}
availableURLs
:=
[]
string
{
"https://ag-1.test"
}
result
:=
handleSmartRetry
(
params
,
resp
,
respBody
,
"https://ag-1.test"
,
0
,
availableURLs
)
svc
:=
&
AntigravityGatewayService
{}
result
:=
svc
.
handleSmartRetry
(
params
,
resp
,
respBody
,
"https://ag-1.test"
,
0
,
availableURLs
)
require
.
NotNil
(
t
,
result
)
require
.
NotNil
(
t
,
result
)
require
.
Equal
(
t
,
smartRetryActionBreakWithResp
,
result
.
action
)
require
.
Equal
(
t
,
smartRetryActionBreakWithResp
,
result
.
action
)
...
...
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