Skip to content

Commit

Permalink
Make relative path test more rigid
Browse files Browse the repository at this point in the history
As it was, it could break if a file named “File” existed in the execution directory
  • Loading branch information
JohnSundell committed Feb 1, 2017
1 parent 0b3830f commit 1f278a1
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions Tests/FilesTests/FilesTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,9 @@ class FilesTests: XCTestCase {
performTest {
try folder.createFile(named: "file")

// Before moving to the parent folder, accessing the file with a relative path should produce nil
XCTAssertNil(try? File(path: "file"))
// Make sure we're not already in the file's parent directory
XCTAssertNotEqual(FileManager.default.currentDirectoryPath, folder.path)

// Move to the parent directory, now a relative path should work
XCTAssertTrue(FileManager.default.changeCurrentDirectoryPath(folder.path))
let file = try File(path: "file")
try XCTAssertEqual(file.read(), Data())
Expand Down

0 comments on commit 1f278a1

Please sign in to comment.