diff --git a/Tests/PathTests/PathTests.swift b/Tests/PathTests/PathTests.swift index ec30699..9cb22af 100644 --- a/Tests/PathTests/PathTests.swift +++ b/Tests/PathTests/PathTests.swift @@ -352,13 +352,13 @@ class PathTests: XCTestCase { XCTAssertThrowsError(try JSONDecoder().decode([Path].self, from: data)) } - func testBundleExtensions() { - XCTAssertTrue(Bundle.main.path.isDirectory) - XCTAssertTrue(Bundle.main.resources.isDirectory) - - // don’t exist in tests - _ = Bundle.main.path(forResource: "foo", ofType: "bar") - _ = Bundle.main.sharedFrameworks + func testBundleExtensions() throws { + try Path.mktemp { tmpdir in + let bndl = Bundle(path: tmpdir.string)! + XCTAssertEqual(bndl.path, tmpdir) + XCTAssertEqual(bndl.sharedFrameworks, tmpdir.SharedFrameworks) + XCTAssertEqual(bndl.resources, tmpdir) + } } func testDataExtensions() throws { @@ -394,7 +394,17 @@ class PathTests: XCTestCase { XCTAssertThrowsError(try bar.touch()) try bar.unlock() try bar.touch() + + // a non existant file is already “unlocked” + try tmpdir.nonExit.unlock() } #endif } + + func testTouchThrowsIfCannotWrite() throws { + try Path.mktemp { tmpdir in + try tmpdir.chmod(0o000) + XCTAssertThrowsError(try tmpdir.bar.touch()) + } + } } diff --git a/Tests/PathTests/XCTestManifests.swift b/Tests/PathTests/XCTestManifests.swift index 6e64f54..5aa2d89 100644 --- a/Tests/PathTests/XCTestManifests.swift +++ b/Tests/PathTests/XCTestManifests.swift @@ -33,6 +33,7 @@ extension PathTests { ("testStringConvertibles", testStringConvertibles), ("testStringExtensions", testStringExtensions), ("testTimes", testTimes), + ("testTouchThrowsIfCannotWrite", testTouchThrowsIfCannotWrite), ] }