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)
|
||||
}
|
||||
|
||||
// ========== IsTokenVersionStale 测试 ==========
|
||||
// ========== CheckTokenVersion 测试 ==========
|
||||
|
||||
func TestIsTokenVersionStale(t *testing.T) {
|
||||
func TestCheckTokenVersion(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
account *Account
|
||||
@@ -496,16 +496,16 @@ func TestIsTokenVersionStale(t *testing.T) {
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
// 由于 IsTokenVersionStale 接受 AccountRepository 接口,而创建完整的 mock 很繁琐
|
||||
// 由于 CheckTokenVersion 接受 AccountRepository 接口,而创建完整的 mock 很繁琐
|
||||
// 这里我们直接测试函数的核心逻辑来验证行为
|
||||
|
||||
if tt.name == "nil_account" {
|
||||
result := IsTokenVersionStale(context.Background(), nil, nil)
|
||||
require.Equal(t, tt.expectedStale, result)
|
||||
_, isStale := CheckTokenVersion(context.Background(), nil, nil)
|
||||
require.Equal(t, tt.expectedStale, isStale)
|
||||
return
|
||||
}
|
||||
|
||||
// 模拟 IsTokenVersionStale 的核心逻辑
|
||||
// 模拟 CheckTokenVersion 的核心逻辑
|
||||
account := tt.account
|
||||
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{
|
||||
ID: 1,
|
||||
Credentials: map[string]any{"_token_version": int64(100)},
|
||||
}
|
||||
result := IsTokenVersionStale(context.Background(), account, nil)
|
||||
require.False(t, result) // nil repo,默认允许缓存
|
||||
_, isStale := CheckTokenVersion(context.Background(), account, nil)
|
||||
require.False(t, isStale) // nil repo,默认允许缓存
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user