Skip to content

Commit

Permalink
Add availability checks to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ffried committed Jan 4, 2021
1 parent d269664 commit a5afadc
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion Tests/AppInformationTests/AppInfoTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,17 @@ final class AppInfoTests: XCTestCase {

private var bundlePath: String!

private func tempDir() -> URL {
if #available(iOS 10, tvOS 10, watchOS 3.0, *) {
return FileManager.default.temporaryDirectory
} else {
return URL(fileURLWithPath: NSTemporaryDirectory())
}
}

override func setUpWithError() throws {
try super.setUpWithError()
bundlePath = FileManager.default.temporaryDirectory
bundlePath = tempDir()
.appendingPathComponent(UUID().uuidString, isDirectory: true)
.appendingPathExtension("bundle")
.path
Expand Down Expand Up @@ -178,6 +186,9 @@ final class AppInfoTests: XCTestCase {

func testSwiftUIEnvironment() throws {
#if canImport(SwiftUI) && canImport(Combine)
guard #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) else {
throw XCTSkip()
}
let info = AppInfo(bundle: FakeBundle(path: bundlePath))
var env = EnvironmentValues()
XCTAssertEqual(env.appInfo, .current)
Expand Down

0 comments on commit a5afadc

Please sign in to comment.