mirror of
https://github.com/maxgoedjen/secretive.git
synced 2026-03-06 01:37:22 +01:00
Swift 6 / Concurrency fixes (#578)
* Enable language mode
* WIP
* WIP
* Fix concurrency issues in SmartCardStore
* Switch to SMAppService
* Bump runners
* Base
* Finish Testing migration
* Tweak async for updater
* More
* Backport mutex
* Revert "Backport mutex"
This reverts commit 9b02afb20c.
* WIP
* Reenable
* Fix preview.
* Update package.
* Bump to latest public macOS and Xcode
* Bump back down to 6.1
* Update to Xcode 26.
* Fixed tests.
* More cleanup
* Env fixes
* var->let
* Cleanup
* Persist auth async
* Whitespace.
* Whitespace.
* Cleanup.
* Cleanup
* Redoing locks in actors bc of observable
* Actors.
* .
* Specify b5
* Update package to 6.2
* Fix disabled updater
* Remove preconcurrency warning
* Move updater init
This commit is contained in:
@@ -1,54 +1,65 @@
|
||||
import XCTest
|
||||
import Testing
|
||||
import Foundation
|
||||
@testable import Brief
|
||||
|
||||
class ReleaseParsingTests: XCTestCase {
|
||||
@Suite struct ReleaseParsingTests {
|
||||
|
||||
func testNonCritical() {
|
||||
@Test
|
||||
func nonCritical() {
|
||||
let release = Release(name: "1.0.0", prerelease: false, html_url: URL(string: "https://example.com")!, body: "Initial release")
|
||||
XCTAssert(release.critical == false)
|
||||
#expect(release.critical == false)
|
||||
}
|
||||
|
||||
func testCritical() {
|
||||
@Test
|
||||
func critical() {
|
||||
let release = Release(name: "1.0.0", prerelease: false, html_url: URL(string: "https://example.com")!, body: "Critical Security Update")
|
||||
XCTAssert(release.critical == true)
|
||||
#expect(release.critical == true)
|
||||
}
|
||||
|
||||
func testOSMissing() {
|
||||
@Test
|
||||
func osMissing() {
|
||||
let release = Release(name: "1.0.0", prerelease: false, html_url: URL(string: "https://example.com")!, body: "Critical Security Update")
|
||||
XCTAssert(release.minimumOSVersion == SemVer("11.0.0"))
|
||||
#expect(release.minimumOSVersion == SemVer("11.0.0"))
|
||||
}
|
||||
|
||||
func testOSPresentWithContentBelow() {
|
||||
@Test
|
||||
func osPresentWithContentBelow() {
|
||||
let release = Release(name: "1.0.0", prerelease: false, html_url: URL(string: "https://example.com")!, body: "Critical Security Update ##Minimum macOS Version\n1.2.3\nBuild info")
|
||||
XCTAssert(release.minimumOSVersion == SemVer("1.2.3"))
|
||||
#expect(release.minimumOSVersion == SemVer("1.2.3"))
|
||||
}
|
||||
|
||||
func testOSPresentAtEnd() {
|
||||
@Test
|
||||
func osPresentAtEnd() {
|
||||
let release = Release(name: "1.0.0", prerelease: false, html_url: URL(string: "https://example.com")!, body: "Critical Security Update Minimum macOS Version: 1.2.3")
|
||||
XCTAssert(release.minimumOSVersion == SemVer("1.2.3"))
|
||||
#expect(release.minimumOSVersion == SemVer("1.2.3"))
|
||||
}
|
||||
|
||||
func testOSWithMacOSPrefix() {
|
||||
@Test
|
||||
func osWithMacOSPrefix() {
|
||||
let release = Release(name: "1.0.0", prerelease: false, html_url: URL(string: "https://example.com")!, body: "Critical Security Update Minimum macOS Version: macOS 1.2.3")
|
||||
XCTAssert(release.minimumOSVersion == SemVer("1.2.3"))
|
||||
#expect(release.minimumOSVersion == SemVer("1.2.3"))
|
||||
}
|
||||
|
||||
func testOSGreaterThanMinimum() {
|
||||
@Test
|
||||
func osGreaterThanMinimum() {
|
||||
let release = Release(name: "1.0.0", prerelease: false, html_url: URL(string: "https://example.com")!, body: "Critical Security Update Minimum macOS Version: 1.2.3")
|
||||
XCTAssert(release.minimumOSVersion < SemVer("11.0.0"))
|
||||
#expect(release.minimumOSVersion < SemVer("11.0.0"))
|
||||
}
|
||||
|
||||
func testOSEqualToMinimum() {
|
||||
@Test
|
||||
func osEqualToMinimum() {
|
||||
let release = Release(name: "1.0.0", prerelease: false, html_url: URL(string: "https://example.com")!, body: "Critical Security Update Minimum macOS Version: 11.2.3")
|
||||
XCTAssert(release.minimumOSVersion <= SemVer("11.2.3"))
|
||||
#expect(release.minimumOSVersion <= SemVer("11.2.3"))
|
||||
}
|
||||
|
||||
func testOSLessThanMinimum() {
|
||||
@Test
|
||||
func osLessThanMinimum() {
|
||||
let release = Release(name: "1.0.0", prerelease: false, html_url: URL(string: "https://example.com")!, body: "Critical Security Update Minimum macOS Version: 1.2.3")
|
||||
XCTAssert(release.minimumOSVersion > SemVer("1.0.0"))
|
||||
#expect(release.minimumOSVersion > SemVer("1.0.0"))
|
||||
}
|
||||
|
||||
func testGreatestSelectedIfOldPatchIsPublishedLater() {
|
||||
@Test
|
||||
@MainActor func greatestSelectedIfOldPatchIsPublishedLater() async throws {
|
||||
// If 2.x.x series has been published, and a patch for 1.x.x is issued
|
||||
// 2.x.x should still be selected if user can run it.
|
||||
let updater = Updater(checkOnLaunch: false, osVersion: SemVer("2.2.3"), currentVersion: SemVer("1.0.0"))
|
||||
@@ -60,16 +71,13 @@ class ReleaseParsingTests: XCTestCase {
|
||||
Release(name: "1.0.2", prerelease: false, html_url: URL(string: "https://example.com")!, body: "Emergency patch! Minimum macOS Version: 1.2.3"),
|
||||
]
|
||||
|
||||
let expectation = XCTestExpectation()
|
||||
updater.evaluate(releases: releases)
|
||||
DispatchQueue.main.async {
|
||||
XCTAssert(updater.update == two)
|
||||
expectation.fulfill()
|
||||
}
|
||||
wait(for: [expectation], timeout: 1)
|
||||
await updater.evaluate(releases: releases)
|
||||
try await Task.sleep(nanoseconds: 1)
|
||||
#expect(updater.update == two)
|
||||
}
|
||||
|
||||
func testLatestVersionIsRunnable() {
|
||||
@Test
|
||||
@MainActor func latestVersionIsRunnable() async throws {
|
||||
// If the 2.x.x series has been published but the user can't run it
|
||||
// the last version the user can run should be selected.
|
||||
let updater = Updater(checkOnLaunch: false, osVersion: SemVer("1.2.3"), currentVersion: SemVer("1.0.0"))
|
||||
@@ -80,16 +88,13 @@ class ReleaseParsingTests: XCTestCase {
|
||||
Release(name: "2.0.0", prerelease: false, html_url: URL(string: "https://example.com")!, body: "2.0 available! Minimum macOS Version: 2.2.3"),
|
||||
Release(name: "1.0.2", prerelease: false, html_url: URL(string: "https://example.com")!, body: "Emergency patch! Minimum macOS Version: 1.2.3"),
|
||||
]
|
||||
let expectation = XCTestExpectation()
|
||||
updater.evaluate(releases: releases)
|
||||
DispatchQueue.main.async {
|
||||
XCTAssert(updater.update == oneOhTwo)
|
||||
expectation.fulfill()
|
||||
}
|
||||
wait(for: [expectation], timeout: 1)
|
||||
await updater.evaluate(releases: releases)
|
||||
try await Task.sleep(nanoseconds: 1)
|
||||
#expect(updater.update == oneOhTwo)
|
||||
}
|
||||
|
||||
func testSorting() {
|
||||
@Test
|
||||
func sorting() {
|
||||
let two = Release(name: "2.0.0", prerelease: false, html_url: URL(string: "https://example.com")!, body: "2.0 available!")
|
||||
let releases = [
|
||||
Release(name: "1.0.0", prerelease: false, html_url: URL(string: "https://example.com")!, body: "Initial release"),
|
||||
@@ -98,7 +103,7 @@ class ReleaseParsingTests: XCTestCase {
|
||||
Release(name: "1.0.2", prerelease: false, html_url: URL(string: "https://example.com")!, body: "Emergency patch!"),
|
||||
]
|
||||
let sorted = releases.sorted().reversed().first
|
||||
XCTAssert(sorted == two)
|
||||
#expect(sorted == two)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,51 +1,52 @@
|
||||
import XCTest
|
||||
import Testing
|
||||
import Foundation
|
||||
@testable import Brief
|
||||
|
||||
class SemVerTests: XCTestCase {
|
||||
@Suite struct SemVerTests {
|
||||
|
||||
func testEqual() {
|
||||
@Test func equal() {
|
||||
let current = SemVer("1.0.2")
|
||||
let old = SemVer("1.0.2")
|
||||
XCTAssert(!(current > old))
|
||||
#expect(!(current > old))
|
||||
}
|
||||
|
||||
func testPatchGreaterButMinorLess() {
|
||||
@Test func patchGreaterButMinorLess() {
|
||||
let current = SemVer("1.1.0")
|
||||
let old = SemVer("1.0.2")
|
||||
XCTAssert(current > old)
|
||||
#expect(current > old)
|
||||
}
|
||||
|
||||
func testMajorSameMinorGreater() {
|
||||
@Test func majorSameMinorGreater() {
|
||||
let current = SemVer("1.0.2")
|
||||
let new = SemVer("1.0.3")
|
||||
XCTAssert(current < new)
|
||||
#expect(current < new)
|
||||
}
|
||||
|
||||
func testMajorGreaterMinorLesser() {
|
||||
@Test func majorGreaterMinorLesser() {
|
||||
let current = SemVer("1.0.2")
|
||||
let new = SemVer("2.0.0")
|
||||
XCTAssert(current < new)
|
||||
#expect(current < new)
|
||||
}
|
||||
|
||||
func testRegularParsing() {
|
||||
@Test func regularParsing() {
|
||||
let current = SemVer("1.0.2")
|
||||
XCTAssert(current.versionNumbers == [1, 0, 2])
|
||||
#expect(current.versionNumbers == [1, 0, 2])
|
||||
}
|
||||
|
||||
func testNoPatch() {
|
||||
@Test func noPatch() {
|
||||
let current = SemVer("1.1")
|
||||
XCTAssert(current.versionNumbers == [1, 1, 0])
|
||||
#expect(current.versionNumbers == [1, 1, 0])
|
||||
}
|
||||
|
||||
func testGarbage() {
|
||||
@Test func garbage() {
|
||||
let current = SemVer("Test")
|
||||
XCTAssert(current.versionNumbers == [0, 0, 0])
|
||||
#expect(current.versionNumbers == [0, 0, 0])
|
||||
}
|
||||
|
||||
func testBeta() {
|
||||
@Test func beta() {
|
||||
let current = SemVer("1.0.2")
|
||||
let new = SemVer("1.1.0_beta1")
|
||||
XCTAssert(current < new)
|
||||
#expect(current < new)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user