viirya commented on code in PR #599: URL: https://github.com/apache/spark-connect-swift/pull/599#discussion_r4299243107
########## Tests/SparkConnectTests/UDFRegistrationTests.swift: ########## @@ -0,0 +1,51 @@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#if canImport(FoundationEssentials) +import FoundationEssentials +#else +import Foundation +#endif +import Testing + +@testable import SparkConnect + +/// A test suite for `UDFRegistration` +@Suite(.serialized) +struct UDFRegistrationTests { + + @Test + func registerJavaWithUnknownClass() async throws { + let spark = try await SparkSession.builder.getOrCreate() + let error = await #expect(throws: Error.self) { + try await spark.udf.registerJava("java_udf", "org.apache.spark.NoSuchUDF", .string) + } + #expect("\(String(describing: error))".contains("NoSuchUDF")) Review Comment: nit: `#expect(throws:)` returns an optional, which is why the `String(describing:)` wrapping is needed here, and then it gets interpolated again. `#require(throws:)` returns the error itself, so this could be: ```swift let error = try await #require(throws: Error.self) { try await spark.udf.registerJava("java_udf", "org.apache.spark.NoSuchUDF", .string) } #expect("\(error)".contains("NoSuchUDF")) ``` This also matches `SparkConnectErrorTests`. The same applies to line 48. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
