Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions Tests/SparkConnectTests/SQLTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import SparkConnect
struct SQLTests {
let fm = FileManager.default
let path = Bundle.module.path(forResource: "queries", ofType: "")!
let encoder = JSONEncoder()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit. This was an unused variable.

let regenerateGoldenFiles = ProcessInfo.processInfo.environment["SPARK_GENERATE_GOLDEN_FILES"] == "1"

let regexID = /#\d+L?/
let regexPlanId = /plan_id=\d+/
Expand Down Expand Up @@ -79,8 +79,13 @@ struct SQLTests {

let sql = try String(contentsOf: URL(fileURLWithPath: "\(path)/\(name)"), encoding: .utf8)
let answer = cleanUp(try await spark.sql(sql).collect().map { $0.toString() }.joined(separator: "\n"))
let expected = cleanUp(try String(contentsOf: URL(fileURLWithPath: "\(path)/\(name).answer"), encoding: .utf8))
#expect(answer == expected.trimmingCharacters(in: .whitespacesAndNewlines))
if (regenerateGoldenFiles) {
let path = "\(FileManager.default.currentDirectoryPath)/Tests/SparkConnectTests/Resources/queries/\(name).answer"
fm.createFile(atPath: path, contents: (answer + "\n").data(using: .utf8)!, attributes: nil)
} else {
let expected = cleanUp(try String(contentsOf: URL(fileURLWithPath: "\(path)/\(name).answer"), encoding: .utf8))
#expect(answer == expected.trimmingCharacters(in: .whitespacesAndNewlines))
}
}
await spark.stop()
}
Expand Down
Loading