I'm trying to make a swift command line tool and have a helper function that checks for environment variables. But how can I unit test this function / mock ProcessInfo?
func withEnv(_ key: String) -> String {
guard let value = ProcessInfo.processInfo.environment[key] else {
print("Missing environment variable: \(key)")
exit(1)
}
return value
}