From e179158d0ed5bd798e3d54a9385559ce7f676ace Mon Sep 17 00:00:00 2001 From: Adam Young Date: Mon, 16 Sep 2024 18:56:53 +0100 Subject: [PATCH] Fix concurrency issue --- .../Utility/CredentialHelper.swift | 29 +++++++------------ 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/Tests/TMDbIntegrationTests/Utility/CredentialHelper.swift b/Tests/TMDbIntegrationTests/Utility/CredentialHelper.swift index fae3c8e3..85c31f17 100644 --- a/Tests/TMDbIntegrationTests/Utility/CredentialHelper.swift +++ b/Tests/TMDbIntegrationTests/Utility/CredentialHelper.swift @@ -20,36 +20,27 @@ import Foundation import TMDb -final class CredentialHelper { +final class CredentialHelper: Sendable { static let shared = CredentialHelper() - private let processInfo: ProcessInfo - - private init(processInto: ProcessInfo = ProcessInfo.processInfo) { - self.processInfo = processInto - } + let tmdbCredential: Credential + let tmdbAPIKey: String var hasCredential: Bool { - let credential = self.tmdbCredential + !tmdbCredential.username.isEmpty && !tmdbCredential.password.isEmpty + } - return !credential.username.isEmpty && !credential.password.isEmpty + var hasAPIKey: Bool { + !tmdbAPIKey.isEmpty } - lazy var tmdbCredential: Credential = { + private init(processInfo: ProcessInfo = ProcessInfo.processInfo) { let username = processInfo.environment["TMDB_USERNAME"] ?? "" let password = processInfo.environment["TMDB_PASSWORD"] ?? "" - let credential = Credential(username: username, password: password) + self.tmdbCredential = Credential(username: username, password: password) - return credential - }() - - var hasAPIKey: Bool { - !self.tmdbAPIKey.isEmpty + self.tmdbAPIKey = processInfo.environment["TMDB_API_KEY"] ?? "" } - lazy var tmdbAPIKey: String = { - processInfo.environment["TMDB_API_KEY"] ?? "" - }() - }