More coverage
This commit is contained in:
@@ -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)
|
||||||
// don’t 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())
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ extension PathTests {
|
|||||||
("testStringConvertibles", testStringConvertibles),
|
("testStringConvertibles", testStringConvertibles),
|
||||||
("testStringExtensions", testStringExtensions),
|
("testStringExtensions", testStringExtensions),
|
||||||
("testTimes", testTimes),
|
("testTimes", testTimes),
|
||||||
|
("testTouchThrowsIfCannotWrite", testTouchThrowsIfCannotWrite),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user