Remaining code coverage

Can’t do coverage for Linux unfortunately.
This commit is contained in:
Max Howell
2019-01-31 13:08:54 -05:00
parent 7970c4d8a7
commit ec6c0113f9
3 changed files with 38 additions and 2 deletions

View File

@@ -266,4 +266,4 @@ https://codebasesaga.com/canopy/
[badge-ci]: https://travis-ci.com/mxcl/Path.swift.svg
[travis]: https://travis-ci.com/mxcl/Path.swift
[codecov]: https://codecov.io/gh/mxcl/Path.swift
[badge-version]: https://img.shields.io/cocoapods/v/Path.swift.svg?label=version
[badge-version]: https://img.shields.io/cocoapods/v/Path.swift.svg?label=version

View File

@@ -164,6 +164,14 @@ class PathTests: XCTestCase {
XCTAssertEqual(a.Documents, Path.home/"foo/Documents")
}
func testCopyTo() throws {
try Path.mktemp { root in
try root.foo.touch().copy(to: root.bar)
XCTAssert(root.foo.isFile)
XCTAssert(root.bar.isFile)
}
}
func testCopyInto() throws {
try Path.mktemp { root1 in
let bar1 = try root1.join("bar").touch()
@@ -177,6 +185,14 @@ class PathTests: XCTestCase {
}
}
func testMoveTo() throws {
try Path.mktemp { root in
try root.foo.touch().move(to: root.bar)
XCTAssertFalse(root.foo.exists)
XCTAssert(root.bar.isFile)
}
}
func testMoveInto() throws {
try Path.mktemp { root1 in
let bar1 = try root1.join("bar").touch()
@@ -313,12 +329,28 @@ class PathTests: XCTestCase {
XCTAssertTrue(Bundle.main.path.isDirectory)
XCTAssertTrue(Bundle.main.resources.isDirectory)
// doesnt exist in tests
// dont exist in tests
_ = Bundle.main.path(forResource: "foo", ofType: "bar")
_ = Bundle.main.sharedFrameworks
}
func testDataExentsions() throws {
let data = try Data(contentsOf: Path(#file)!)
try Path.mktemp { tmpdir in
_ = try data.write(to: tmpdir.foo)
}
}
func testStringExentsions() throws {
let string = try String(contentsOf: Path(#file)!)
try Path.mktemp { tmpdir in
_ = try string.write(to: tmpdir.foo)
}
}
func testFileHandleExtensions() throws {
_ = try FileHandle(forReadingAt: Path(#file)!)
_ = try FileHandle(forWritingAt: Path(#file)!)
_ = try FileHandle(forUpdatingAt: Path(#file)!)
}
}

View File

@@ -8,6 +8,8 @@ extension PathTests {
("testCommonDirectories", testCommonDirectories),
("testConcatenation", testConcatenation),
("testCopyInto", testCopyInto),
("testCopyTo", testCopyTo),
("testDataExentsions", testDataExentsions),
("testDelete", testDelete),
("testDynamicMember", testDynamicMember),
("testEnumeration", testEnumeration),
@@ -21,11 +23,13 @@ extension PathTests {
("testMkpathIfExists", testMkpathIfExists),
("testMktemp", testMktemp),
("testMoveInto", testMoveInto),
("testMoveTo", testMoveTo),
("testRelativeCodable", testRelativeCodable),
("testRelativePathCodable", testRelativePathCodable),
("testRelativeTo", testRelativeTo),
("testRename", testRename),
("testStringConvertibles", testStringConvertibles),
("testStringExentsions", testStringExentsions),
("testTimes", testTimes),
]
}