Merge pull request #28 from mxcl/codecov

More coverage
This commit is contained in:
Max Howell
2019-01-31 19:17:43 -05:00
committed by GitHub
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))
}
func testBundleExtensions() {
XCTAssertTrue(Bundle.main.path.isDirectory)
XCTAssertTrue(Bundle.main.resources.isDirectory)
// dont 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())
}
}
}

View File

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