Run Windows games on Apple Silicon — free, open source, with an open compatibility database that tells you what actually works.
Swift apple-silicond3dmetaldxmtdxvkfexgame-porting-toolkitgamingmac-gamingmacosmetalmoltenvksteamswiftuivkd3d-protonwhisky-alternativewindows-gameswinewine-wrapper
Steam accounts: tests for first sign-ins and when a game appeared in the library
Gabea1215686f050
diff --git a/Tests/HighballKitTests/SteamAccountsTests.swift b/Tests/HighballKitTests/SteamAccountsTests.swiftindex 474f303..55c329d 100644--- a/Tests/HighballKitTests/SteamAccountsTests.swift+++ b/Tests/HighballKitTests/SteamAccountsTests.swift@@ -154,6 +154,25 @@ final class SteamAccountsTests: XCTestCase {SteamAccounts.Owners(accounts: [alder], reason: .installed), "an empty choice is no choice")}+ /// Each account's first sign-in is when Steam made its userdata folder, named by the 32-bit+ /// account ID; other folders there are no account's.+ func testFirstSignInsComeFromTheUserdataFolders() throws {+ let root = FileManager.default.temporaryDirectory.appending(path: "hb-accounts-\(UUID())/Steam")+ addTeardownBlock { try? FileManager.default.removeItem(at: root.deletingLastPathComponent()) }+ let userdata = root.appending(path: "userdata")+ let first = Date(timeIntervalSince1970: 1_600_000_000), second = Date(timeIntervalSince1970: 1_600_086_400)+ for (folder, made) in [("39734273", first), ("39734274", second), ("anonymous", first)] {+ let url = userdata.appending(path: folder)+ try FileManager.default.createDirectory(at: url, withIntermediateDirectories: true)+ try FileManager.default.setAttributes([.creationDate: made], ofItemAtPath: url.path)+ }+ let signIns = SteamAccounts.firstSignIns(steamRoot: root)+ XCTAssertEqual(Set(signIns.keys), [SteamAccounts.steamIDBase + 39734273, SteamAccounts.steamIDBase + 39734274])+ XCTAssertEqual(signIns[SteamAccounts.steamIDBase + 39734273]?.timeIntervalSince1970 ?? 0, first.timeIntervalSince1970, accuracy: 1)+ XCTAssertEqual(signIns[SteamAccounts.steamIDBase + 39734274]?.timeIntervalSince1970 ?? 0, second.timeIntervalSince1970, accuracy: 1)+ XCTAssertEqual(SteamAccounts.firstSignIns(steamRoot: root.appending(path: "nowhere")), [:], "no userdata: nobody")+ }+/// Games that appeared while only the first account had ever signed in are its; later ones/// are nobody's here until seen arriving.func testGamesFromBeforeASecondAccountAreTheFirstOnes() {diff --git a/Tests/HighballKitTests/SteamOwnedLibraryTests.swift b/Tests/HighballKitTests/SteamOwnedLibraryTests.swiftindex ee21e1f..2e5720e 100644--- a/Tests/HighballKitTests/SteamOwnedLibraryTests.swift+++ b/Tests/HighballKitTests/SteamOwnedLibraryTests.swift@@ -155,6 +155,20 @@ final class SteamOwnedLibraryTests: XCTestCase {XCTAssertEqual(dsr.capsuleImage.host, "cdn.akamai.steamstatic.com", "no local art: the CDN")}+ /// When a game first appeared in the library: when the client made its librarycache folder+ /// (SteamAccounts.earlyArrivals).+ func testCachedAtIsWhenTheLibraryCacheFolderWasMade() throws {+ let root = try steamRoot(owned: [1145360, 570940], appinfo: appinfo(apps))+ let made = Date(timeIntervalSince1970: 1_600_000_000)+ try FileManager.default.setAttributes([.creationDate: made],+ ofItemAtPath: root.appending(path: "appcache/librarycache/570940").path)+ let games = SteamOwnedLibrary.games(steamRoot: root)+ let dsr = try XCTUnwrap(games.first { $0.appid == 570940 }?.cachedAt)+ XCTAssertEqual(dsr.timeIntervalSince1970, made.timeIntervalSince1970, accuracy: 1)+ let hades = try XCTUnwrap(games.first { $0.appid == 1145360 }?.cachedAt)+ XCTAssertGreaterThan(hades, made, "a folder made just now")+ }+func testNothingBeforeFirstSignIn() throws {XCTAssertEqual(SteamOwnedLibrary.games(steamRoot: try steamRoot(owned: [], appinfo: nil)), [])XCTAssertEqual(SteamOwnedLibrary.games(steamRoot: try steamRoot(owned: [570940], appinfo: nil)), [])