From 4457d6201a052e7160d94bfdcf4aa74b5cbc08e7 Mon Sep 17 00:00:00 2001 From: ysicing Date: Mon, 21 Sep 2026 19:10:20 +0800 Subject: [PATCH] =?UTF-8?q?test(update):=20=E7=A7=BB=E9=99=A4=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E5=8C=96=E9=94=99=E8=AF=AF=E6=96=87=E6=9C=AC=E4=BE=9D?= =?UTF-8?q?=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tests/UpdatesTests/UpdateFeedTests.swift | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Packages/XStatsKit/Tests/UpdatesTests/UpdateFeedTests.swift b/Packages/XStatsKit/Tests/UpdatesTests/UpdateFeedTests.swift index bdab504..3e896a4 100644 --- a/Packages/XStatsKit/Tests/UpdatesTests/UpdateFeedTests.swift +++ b/Packages/XStatsKit/Tests/UpdatesTests/UpdateFeedTests.swift @@ -80,6 +80,18 @@ import Testing return url } + private func expectInvalidBundle(_ operation: () throws -> Void) { + do { + try operation() + Issue.record("Expected UpdateError.invalidBundle") + } catch let error as UpdateError { + if case .invalidBundle = error { return } + Issue.record("Unexpected update error: \(error)") + } catch { + Issue.record("Unexpected error: \(error)") + } + } + @Test func hashesFiles() throws { let dir = try scratch() defer { try? FileManager.default.removeItem(at: dir) } @@ -131,7 +143,7 @@ import Testing #expect(throws: UpdateError.self) { try UpdateInstaller.verify(app, bundleIdentifier: "work.12306.xstats.app", version: "9.9.9", teamIdentifier: "ABCDE12345") } - #expect(throws: UpdateError.invalidBundle("版本是 9.9.9,清单写的是 1.0.0")) { + expectInvalidBundle { try UpdateInstaller.verify(app, bundleIdentifier: "work.12306.xstats.app", version: "1.0.0", teamIdentifier: "ABCDE12345") } } @@ -144,7 +156,7 @@ import Testing let plist = ["CFBundleIdentifier": "com.openstats.app", "CFBundlePackageType": "APPL"] try PropertyListSerialization.data(fromPropertyList: plist, format: .xml, options: 0) .write(to: app.appendingPathComponent("Contents/Info.plist")) - #expect(throws: UpdateError.invalidBundle("包名是 com.openstats.app")) { + expectInvalidBundle { try UpdateInstaller.verify(app, bundleIdentifier: "work.12306.xstats.app", version: "0.6.1", teamIdentifier: "ABCDE12345") } }