Skip to content

Commit 3b8c923

Browse files
committed
Clean up
1 parent 2256467 commit 3b8c923

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

Tests/SparkConnectTests/SQLTests.swift

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ struct SQLTests {
3030

3131
let regexID = /#\d+L?/
3232
let regexPlanId = /plan_id=\d+/
33-
let regexLocation = /file:\w+/
33+
let regexLocation = /file:\S+/
34+
35+
private func cleanUp(_ str: String) -> String {
36+
return removeID(removeLocation(str))
37+
}
3438

3539
private func removeID(_ str: String) -> String {
3640
return str.replacing(regexPlanId, with: "plan_id=").replacing(regexID, with: "#")
@@ -49,6 +53,11 @@ struct SQLTests {
4953
#expect(removeID("plan_id=123") == "plan_id=")
5054
}
5155

56+
@Test
57+
func removeLocation() {
58+
#expect(removeLocation("file:/abc") == "*")
59+
}
60+
5261
#if !os(Linux)
5362
@Test
5463
func runAll() async throws {
@@ -59,8 +68,8 @@ struct SQLTests {
5968

6069
let sql = try String(contentsOf: URL(fileURLWithPath: "\(path)/\(name)"), encoding: .utf8)
6170
let jsonData = try encoder.encode(try await spark.sql(sql).collect())
62-
let answer = removeID(String(data: jsonData, encoding: .utf8)!)
63-
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))
6473
#expect(answer == expected.trimmingCharacters(in: .whitespacesAndNewlines))
6574
}
6675
await spark.stop()

0 commit comments

Comments
 (0)