Files
suixinkan_ios_new/suixinkanTests/APIErrorTests.swift
2026-06-22 11:28:01 +08:00

30 lines
1.1 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// APIErrorTests.swift
// suixinkanTests
//
// Created by Codex on 2026/6/20.
//
import XCTest
@testable import suixinkan
///
final class APIErrorTests: XCTestCase {
/// HTTP 401 403
func testAuthenticationExpiredForUnauthorizedHTTPStatus() {
XCTAssertTrue(APIError.isAuthenticationExpired(APIError.httpStatus(401, "Unauthorized")))
XCTAssertTrue(APIError.isAuthenticationExpired(APIError.httpStatus(403, "Forbidden")))
}
///
func testAuthenticationExpiredForServerTokenMessages() {
XCTAssertTrue(APIError.isAuthenticationExpired(APIError.serverCode(200001, "token 已过期")))
XCTAssertTrue(APIError.isAuthenticationExpired(APIError.serverCode(0, "登录失效,请重新登录")))
}
///
func testNetworkErrorIsNotAuthenticationExpired() {
XCTAssertFalse(APIError.isAuthenticationExpired(APIError.networkFailed("请求超时,请稍后重试")))
}
}