Files
ShadowsocksX-NG/ShadowsocksX-NG2/Tests/Subscription/SubscriptionRefreshFailureTests.swift
Qiu YuzhouandDeepSeek Harness 5872015ca0 test: drop dead scaffolding assertions
Six sites re-asserted the predicate waitUntilRuntimeSettles already checks,
with no suspension point in between, so they could never fail; their intent
messages are folded into comments where one was not already stated.

Two commit-failure cases asserted the fake's bookkeeping (updateCalls stays
empty) which the fake guarantees by throwing before recording; the outcome
and committed-snapshot assertions already prove the real behavior.

Also drop a no-op loop that mutated a discarded struct copy, a duplicated
isWellFormed line, two WorkspaceRoute cases subsumed by the constructor and
the publish-count case, a duplicated presentation-message assertion, and the
round-trip halves of two payload-shape cases already covered case-by-case.

Co-Authored-By: DeepSeek Harness <noreply@deepseek.com>
2026-10-21 02:23:28 +08:00

60 lines
1.8 KiB
Swift

import Foundation
import XCTest
@testable import ShadowsocksX_NG2
/// 订阅刷新失败的 durable seam:只观察可演进的安全事实,不观察文案或
/// transient Error 的实现细节。
final class SubscriptionRefreshFailureTests: XCTestCase {
func testAllDurableFailureFactsRoundTrip() throws {
let failures: [SubscriptionRefreshFailure] = [
.invalidURL,
.unsupportedScheme,
.insecureRedirect,
.transport(.timedOut),
.transport(.tls),
.transport(.connection),
.transport(.unknown),
.httpStatus(code: 503),
.contentType(.missing),
.contentType(.unsupported),
.decodingFailure,
.unsupportedSchemaVersion,
.missingServers,
.recordValidation(index: 3, field: .address),
.recordValidation(index: 3, field: .port),
.recordValidation(index: 3, field: .method),
.recordValidation(index: 3, field: .password),
.recordValidation(index: 3, field: .identity),
.duplicateIdentity,
.commit,
.unknown,
]
for failure in failures {
let data = try JSONEncoder().encode(failure)
XCTAssertEqual(try JSONDecoder().decode(SubscriptionRefreshFailure.self, from: data), failure)
}
}
func testHTTPStatusFailurePayloadOmitsInternalReason() throws {
let failure = SubscriptionRefreshFailure.httpStatus(code: 503)
let data = try JSONEncoder().encode(failure)
let json = String(bytes: data, encoding: .utf8) ?? ""
XCTAssertFalse(json.contains("reason"))
}
func testPartialRollbackIsCoarseAndContainsNoCredentialReferences() throws {
let failure = SubscriptionRefreshFailure.commit
let data = try JSONEncoder().encode(failure)
let json = String(bytes: data, encoding: .utf8) ?? ""
XCTAssertFalse(json.contains("credential"))
XCTAssertFalse(json.contains("reference"))
}
}