Skip to content

Commit f6453cc

Browse files
committed
Update integration test to check the URLContextMetadata
1 parent 7977505 commit f6453cc

File tree

1 file changed

+8
-19
lines changed

1 file changed

+8
-19
lines changed

FirebaseAI/Tests/TestApp/Tests/Integration/GenerateContentIntegrationTests.swift

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -441,25 +441,14 @@ struct GenerateContentIntegrationTests {
441441
let response = try await model.generateContent(prompt)
442442

443443
let candidate = try #require(response.candidates.first)
444-
let groundingMetadata = try #require(candidate.groundingMetadata)
445-
#expect(!groundingMetadata.groundingChunks.isEmpty)
446-
#expect(!groundingMetadata.groundingSupports.isEmpty)
447-
448-
for chunk in groundingMetadata.groundingChunks {
449-
#expect(chunk.web != nil)
450-
}
451-
452-
for support in groundingMetadata.groundingSupports {
453-
let segment = support.segment
454-
#expect(segment.endIndex > segment.startIndex)
455-
#expect(!segment.text.isEmpty)
456-
#expect(!support.groundingChunkIndices.isEmpty)
457-
458-
// Ensure indices point to valid chunks
459-
for index in support.groundingChunkIndices {
460-
#expect(index < groundingMetadata.groundingChunks.count)
461-
}
462-
}
444+
let urlContextMetadata = try #require(candidate.urlContextMetadata)
445+
#expect(urlContextMetadata.urlMetadata.count == 1)
446+
let urlMetadata = try #require(urlContextMetadata.urlMetadata.first)
447+
let retrievedURL = try #require(urlMetadata.retrievedURL)
448+
#expect(
449+
retrievedURL == URL(string: "https://developers.googleblog.com/en/introducing-gemma-3-270m/")
450+
)
451+
#expect(urlMetadata.retrievalStatus == .success)
463452
}
464453

465454
// MARK: Streaming Tests

0 commit comments

Comments
 (0)