File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -477,6 +477,27 @@ final class GenerativeModelVertexAITests: XCTestCase {
477
477
XCTAssertGreaterThan ( imagePart. data. count, 0 )
478
478
}
479
479
480
+ func testGenerateContent_success_image_emptyPartIgnored( ) async throws {
481
+ MockURLProtocol . requestHandler = try GenerativeModelTestUtil . httpRequestHandler (
482
+ forResource: " unary-success-empty-part " ,
483
+ withExtension: " json " ,
484
+ subdirectory: vertexSubdirectory
485
+ )
486
+
487
+ let response = try await model. generateContent ( testPrompt)
488
+
489
+ XCTAssertEqual ( response. candidates. count, 1 )
490
+ let candidate = try XCTUnwrap ( response. candidates. first)
491
+ XCTAssertEqual ( candidate. content. parts. count, 2 )
492
+ let inlineDataParts = response. inlineDataParts
493
+ XCTAssertEqual ( inlineDataParts. count, 1 )
494
+ let imagePart = try XCTUnwrap ( inlineDataParts. first)
495
+ XCTAssertEqual ( imagePart. mimeType, " image/png " )
496
+ XCTAssertGreaterThan ( imagePart. data. count, 0 )
497
+ let text = try XCTUnwrap ( response. text)
498
+ XCTAssertTrue ( text. starts ( with: " I can certainly help you with that " ) )
499
+ }
500
+
480
501
func testGenerateContent_appCheck_validToken( ) async throws {
481
502
let appCheckToken = " test-valid-token "
482
503
model = GenerativeModel (
You can’t perform that action at this time.
0 commit comments