@@ -30,11 +30,20 @@ struct SQLTests {
30
30
31
31
let regexID = /#\d+L?/
32
32
let regexPlanId = /plan_id=\d+/
33
+ let regexLocation = /file:[a-zA-Z0-9\-\/ \\] +/
34
+
35
+ private func cleanUp( _ str: String ) -> String {
36
+ return removeID ( removeLocation ( str) )
37
+ }
33
38
34
39
private func removeID( _ str: String ) -> String {
35
40
return str. replacing ( regexPlanId, with: " plan_id= " ) . replacing ( regexID, with: " # " )
36
41
}
37
42
43
+ private func removeLocation( _ str: String ) -> String {
44
+ return str. replacing ( regexLocation, with: " * " )
45
+ }
46
+
38
47
@Test
39
48
func testRemoveID( ) {
40
49
#expect( removeID ( " 123 " ) == " 123 " )
@@ -44,6 +53,11 @@ struct SQLTests {
44
53
#expect( removeID ( " plan_id=123 " ) == " plan_id= " )
45
54
}
46
55
56
+ @Test
57
+ func removeLocation( ) {
58
+ #expect( removeLocation ( " file:/abc " ) == " * " )
59
+ }
60
+
47
61
#if !os(Linux)
48
62
@Test
49
63
func runAll( ) async throws {
@@ -54,8 +68,8 @@ struct SQLTests {
54
68
55
69
let sql = try String ( contentsOf: URL ( fileURLWithPath: " \( path) / \( name) " ) , encoding: . utf8)
56
70
let jsonData = try encoder. encode ( try await spark. sql ( sql) . collect ( ) )
57
- let answer = removeID ( String ( data: jsonData, encoding: . utf8) !)
58
- let expected = removeID ( try String ( contentsOf: URL ( fileURLWithPath: " \( path) / \( name) .json " ) , encoding: . utf8) )
71
+ let answer = cleanUp ( String ( data: jsonData, encoding: . utf8) !)
72
+ let expected = cleanUp ( try String ( contentsOf: URL ( fileURLWithPath: " \( path) / \( name) .json " ) , encoding: . utf8) )
59
73
#expect( answer == expected. trimmingCharacters ( in: . whitespacesAndNewlines) )
60
74
}
61
75
await spark. stop ( )
0 commit comments