More coverage

This commit is contained in:
Max Howell
2019-01-31 16:35:03 -05:00
parent 6b52932e7b
commit b9abd07318
2 changed files with 18 additions and 7 deletions

View File

@@ -352,13 +352,13 @@ class PathTests: XCTestCase {
XCTAssertThrowsError(try JSONDecoder().decode([Path].self, from: data)) XCTAssertThrowsError(try JSONDecoder().decode([Path].self, from: data))
} }
func testBundleExtensions() { func testBundleExtensions() throws {
XCTAssertTrue(Bundle.main.path.isDirectory) try Path.mktemp { tmpdir in
XCTAssertTrue(Bundle.main.resources.isDirectory) let bndl = Bundle(path: tmpdir.string)!
XCTAssertEqual(bndl.path, tmpdir)
// dont exist in tests XCTAssertEqual(bndl.sharedFrameworks, tmpdir.SharedFrameworks)
_ = Bundle.main.path(forResource: "foo", ofType: "bar") XCTAssertEqual(bndl.resources, tmpdir)
_ = Bundle.main.sharedFrameworks }
} }
func testDataExtensions() throws { func testDataExtensions() throws {
@@ -394,7 +394,17 @@ class PathTests: XCTestCase {
XCTAssertThrowsError(try bar.touch()) XCTAssertThrowsError(try bar.touch())
try bar.unlock() try bar.unlock()
try bar.touch() try bar.touch()
// a non existant file is already unlocked
try tmpdir.nonExit.unlock()
} }
#endif #endif
} }
func testTouchThrowsIfCannotWrite() throws {
try Path.mktemp { tmpdir in
try tmpdir.chmod(0o000)
XCTAssertThrowsError(try tmpdir.bar.touch())
}
}
} }

View File

@@ -33,6 +33,7 @@ extension PathTests {
("testStringConvertibles", testStringConvertibles), ("testStringConvertibles", testStringConvertibles),
("testStringExtensions", testStringExtensions), ("testStringExtensions", testStringExtensions),
("testTimes", testTimes), ("testTimes", testTimes),
("testTouchThrowsIfCannotWrite", testTouchThrowsIfCannotWrite),
] ]
} }