Skip to content

Commit 090a75d

Browse files
committed
Refactor progress file parsing and improve test validation
1 parent 4afe65d commit 090a75d

File tree

2 files changed

+0
-24
lines changed

2 files changed

+0
-24
lines changed

Sources/SwiftlyCore/FileManager+FilePath.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -190,13 +190,6 @@ extension String {
190190
try self.write(to: URL(fileURLWithPath: path.string), atomically: atomically, encoding: enc)
191191
}
192192

193-
public func append(to path: FilePath, encoding enc: String.Encoding = .utf8) throws {
194-
if !FileManager.default.fileExists(atPath: path.string) {
195-
try self.write(to: path, atomically: true, encoding: enc)
196-
return
197-
}
198-
}
199-
200193
public init(contentsOf path: FilePath, encoding enc: String.Encoding = .utf8) throws {
201194
try self.init(contentsOf: URL(fileURLWithPath: path.string), encoding: enc)
202195
}

Tests/SwiftlyTests/JsonFileProgressReporterTests.swift

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -100,23 +100,6 @@ import Testing
100100
try FileManager.default.removeItem(atPath: tempFile.string)
101101
}
102102

103-
@Test("Test clear method truncates the file")
104-
func testClearTruncatesFile() async throws {
105-
let tempFile = fs.mktemp(ext: ".json")
106-
try await fs.create(.mode(Int(0o644)), file: tempFile)
107-
defer { try? FileManager.default.removeItem(atPath: tempFile.string) }
108-
let reporter = try JsonFileProgressReporter(SwiftlyTests.ctx, filePath: tempFile)
109-
defer { try? reporter.close() }
110-
111-
reporter.update(step: 1, total: 2, text: "Test")
112-
113-
#expect(try String(contentsOf: tempFile).lengthOfBytes(using: String.Encoding.utf8) > 0)
114-
115-
reporter.clear()
116-
117-
#expect(try String(contentsOf: tempFile).lengthOfBytes(using: String.Encoding.utf8) == 0)
118-
}
119-
120103
@Test("Test multiple progress updates create multiple lines")
121104
func testMultipleUpdatesCreateMultipleLines() async throws {
122105
let tempFile = fs.mktemp(ext: ".json")

0 commit comments

Comments
 (0)