fix(test): 修复测试中引用不存在的函数名
测试文件引用了 IsTokenVersionStale 函数,但实际函数名为 CheckTokenVersion,导致 CI 构建失败
This commit is contained in:
@@ -396,9 +396,9 @@ func TestAccount_GetCredentialAsInt64_NilAccount(t *testing.T) {
|
|||||||
require.Equal(t, int64(0), result)
|
require.Equal(t, int64(0), result)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== IsTokenVersionStale 测试 ==========
|
// ========== CheckTokenVersion 测试 ==========
|
||||||
|
|
||||||
func TestIsTokenVersionStale(t *testing.T) {
|
func TestCheckTokenVersion(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
account *Account
|
account *Account
|
||||||
@@ -496,16 +496,16 @@ func TestIsTokenVersionStale(t *testing.T) {
|
|||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
// 由于 IsTokenVersionStale 接受 AccountRepository 接口,而创建完整的 mock 很繁琐
|
// 由于 CheckTokenVersion 接受 AccountRepository 接口,而创建完整的 mock 很繁琐
|
||||||
// 这里我们直接测试函数的核心逻辑来验证行为
|
// 这里我们直接测试函数的核心逻辑来验证行为
|
||||||
|
|
||||||
if tt.name == "nil_account" {
|
if tt.name == "nil_account" {
|
||||||
result := IsTokenVersionStale(context.Background(), nil, nil)
|
_, isStale := CheckTokenVersion(context.Background(), nil, nil)
|
||||||
require.Equal(t, tt.expectedStale, result)
|
require.Equal(t, tt.expectedStale, isStale)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 模拟 IsTokenVersionStale 的核心逻辑
|
// 模拟 CheckTokenVersion 的核心逻辑
|
||||||
account := tt.account
|
account := tt.account
|
||||||
currentVersion := account.GetCredentialAsInt64("_token_version")
|
currentVersion := account.GetCredentialAsInt64("_token_version")
|
||||||
|
|
||||||
@@ -537,11 +537,11 @@ func TestIsTokenVersionStale(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestIsTokenVersionStale_NilRepo(t *testing.T) {
|
func TestCheckTokenVersion_NilRepo(t *testing.T) {
|
||||||
account := &Account{
|
account := &Account{
|
||||||
ID: 1,
|
ID: 1,
|
||||||
Credentials: map[string]any{"_token_version": int64(100)},
|
Credentials: map[string]any{"_token_version": int64(100)},
|
||||||
}
|
}
|
||||||
result := IsTokenVersionStale(context.Background(), account, nil)
|
_, isStale := CheckTokenVersion(context.Background(), account, nil)
|
||||||
require.False(t, result) // nil repo,默认允许缓存
|
require.False(t, isStale) // nil repo,默认允许缓存
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user