@@ -181,16 +181,20 @@ final class ImagenGenerationResponseTests: XCTestCase {
181
181
let json = " {} "
182
182
let jsonData = try XCTUnwrap ( json. data ( using: . utf8) )
183
183
184
- let response = try decoder. decode (
185
- ImagenGenerationResponse< ImagenInlineImage> . self ,
186
- from: jsonData
187
- )
188
-
189
- XCTAssertEqual ( response. images, [ ] )
190
- XCTAssertNil ( response. filteredReason)
184
+ do {
185
+ let response = try decoder. decode (
186
+ ImagenGenerationResponse< ImagenInlineImage> . self ,
187
+ from: jsonData
188
+ )
189
+ XCTFail ( " Expected a DecodingError, got response: \( response) " )
190
+ } catch let DecodingError . keyNotFound( codingKey, _) {
191
+ XCTAssertEqual ( codingKey. stringValue, " predictions " )
192
+ } catch {
193
+ XCTFail ( " Expected a DecodingError.keyNotFound, got error: \( error) " )
194
+ }
191
195
}
192
196
193
- func testDecodeResponse_multipleFilterReasons_returnsFirst ( ) throws {
197
+ func testDecodeResponse_multipleFilterReasons_concatenatesReasons ( ) throws {
194
198
let raiFilteredReason1 = " filtered-reason-1 "
195
199
let raiFilteredReason2 = " filtered-reason-2 "
196
200
let json = """
@@ -213,8 +217,7 @@ final class ImagenGenerationResponseTests: XCTestCase {
213
217
)
214
218
215
219
XCTAssertEqual ( response. images, [ ] )
216
- XCTAssertEqual ( response. filteredReason, raiFilteredReason1)
217
- XCTAssertNotEqual ( response. filteredReason, raiFilteredReason2)
220
+ XCTAssertEqual ( response. filteredReason, " \( raiFilteredReason1) \n \( raiFilteredReason2) " )
218
221
}
219
222
220
223
func testDecodeResponse_unknownPrediction( ) throws {
0 commit comments