1
1
import Foundation
2
+ @testable import Swiftly
3
+ @testable import SwiftlyCore
2
4
import SystemPackage
3
5
import Testing
4
6
@@ -100,6 +102,20 @@ import Testing
100
102
try FileManager . default. removeItem ( atPath: tempFile. string)
101
103
}
102
104
105
+ @Test ( " Test clear method removes file " )
106
+ func testClearRemovesFile( ) throws {
107
+ let tempFile = fs. mktemp ( ext: " .json " )
108
+ let reporter = JsonFileProgressReporter ( filePath: tempFile)
109
+
110
+ reporter. update ( step: 1 , total: 2 , text: " Test " )
111
+
112
+ #expect( FileManager . default. fileExists ( atPath: tempFile. string) )
113
+
114
+ reporter. clear ( )
115
+
116
+ #expect( !FileManager. default. fileExists ( atPath: tempFile. string) )
117
+ }
118
+
103
119
@Test ( " Test multiple progress updates create multiple lines " )
104
120
func testMultipleUpdatesCreateMultipleLines( ) async throws {
105
121
let tempFile = fs. mktemp ( ext: " .json " )
@@ -113,6 +129,8 @@ import Testing
113
129
reporter. update ( step: 50 , total: 100 , text: " Processing item 50 " )
114
130
reporter. update ( step: 100 , total: 100 , text: " Processing item 100 " )
115
131
132
+ reporter. update ( step: 1 , total: 3 , text: " Step 1 " )
133
+ reporter. update ( step: 2 , total: 3 , text: " Step 2 " )
116
134
reporter. complete ( success: true )
117
135
try ? reporter. close ( )
118
136
0 commit comments