Skip to content

Commit

Permalink
Fix concurrency issue
Browse files Browse the repository at this point in the history
  • Loading branch information
adamayoung committed Sep 16, 2024
1 parent c5ee3bc commit e179158
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions Tests/TMDbIntegrationTests/Utility/CredentialHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"] ?? ""
}()

}

0 comments on commit e179158

Please sign in to comment.