Skip to content

Commit 2dcb05c

Browse files
authored
VertexAI: migrate test cases to use updated set of golden files (#13152)
1 parent b203dc3 commit 2dcb05c

File tree

48 files changed

+175
-153
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+175
-153
lines changed

FirebaseVertexAI/Tests/Unit/ChatTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ final class ChatTests: XCTestCase {
3333

3434
func testMergingText() async throws {
3535
let fileURL = try XCTUnwrap(Bundle.module.url(
36-
forResource: "streaming-success-basic-reply-long",
36+
forResource: "streaming-success-basic-reply-parts",
3737
withExtension: "txt"
3838
))
3939

FirebaseVertexAI/Tests/Unit/GenerateContentResponses/streaming-failure-finish-reason-safety.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

FirebaseVertexAI/Tests/Unit/GenerateContentResponses/streaming-failure-recitation-no-content.txt

Lines changed: 0 additions & 6 deletions
This file was deleted.

FirebaseVertexAI/Tests/Unit/GenerateContentResponses/streaming-success-basic-reply-short.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

FirebaseVertexAI/Tests/Unit/GenerateContentResponses/streaming-success-citations.txt

Lines changed: 0 additions & 7 deletions
This file was deleted.

FirebaseVertexAI/Tests/Unit/GenerateContentResponses/unary-failure-finish-reason-safety.json

Lines changed: 0 additions & 53 deletions
This file was deleted.

FirebaseVertexAI/Tests/Unit/GenerateContentResponses/unary-success-basic-reply-long.json

Lines changed: 0 additions & 50 deletions
This file was deleted.

FirebaseVertexAI/Tests/Unit/GenerativeModelTests.swift

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ final class GenerativeModelTests: XCTestCase {
7171
XCTAssertEqual(candidate.content.parts.count, 1)
7272
let part = try XCTUnwrap(candidate.content.parts.first)
7373
let partText = try XCTUnwrap(part.text)
74-
XCTAssertTrue(partText.hasPrefix("You can ask me a wide range of questions"))
74+
XCTAssertTrue(partText.hasPrefix("1. **Use Freshly Ground Coffee**:"))
7575
XCTAssertEqual(response.text, partText)
7676
XCTAssertEqual(response.functionCalls, [])
7777
}
@@ -92,7 +92,7 @@ final class GenerativeModelTests: XCTestCase {
9292
XCTAssertEqual(candidate.safetyRatings.sorted(), safetyRatingsNegligible)
9393
XCTAssertEqual(candidate.content.parts.count, 1)
9494
let part = try XCTUnwrap(candidate.content.parts.first)
95-
XCTAssertEqual(part.text, "Mountain View, California, United States")
95+
XCTAssertEqual(part.text, "Mountain View, California")
9696
XCTAssertEqual(response.text, part.text)
9797
XCTAssertEqual(response.functionCalls, [])
9898
}
@@ -506,7 +506,7 @@ final class GenerativeModelTests: XCTestCase {
506506
XCTFail("Should throw")
507507
} catch let GenerateContentError.responseStoppedEarly(reason, response) {
508508
XCTAssertEqual(reason, .safety)
509-
XCTAssertEqual(response.text, "No")
509+
XCTAssertEqual(response.text, "<redacted>")
510510
} catch {
511511
XCTFail("Should throw a responseStoppedEarly")
512512
}
@@ -888,7 +888,7 @@ final class GenerativeModelTests: XCTestCase {
888888
responses += 1
889889
}
890890

891-
XCTAssertEqual(responses, 8)
891+
XCTAssertEqual(responses, 6)
892892
}
893893

894894
func testGenerateContentStream_successBasicReplyShort() async throws {
@@ -949,18 +949,14 @@ final class GenerativeModelTests: XCTestCase {
949949

950950
let lastCandidate = try XCTUnwrap(responses.last?.candidates.first)
951951
XCTAssertEqual(lastCandidate.finishReason, .stop)
952-
XCTAssertEqual(citations.count, 3)
952+
XCTAssertEqual(citations.count, 6)
953953
XCTAssertTrue(citations
954954
.contains(where: {
955-
$0.startIndex == 0 && $0.endIndex == 128 && !$0.uri.isEmpty && $0.license == nil
955+
$0.startIndex == 574 && $0.endIndex == 705 && !$0.uri.isEmpty && $0.license == ""
956956
}))
957957
XCTAssertTrue(citations
958958
.contains(where: {
959-
$0.startIndex == 130 && $0.endIndex == 265 && !$0.uri.isEmpty && $0.license == nil
960-
}))
961-
XCTAssertTrue(citations
962-
.contains(where: {
963-
$0.startIndex == 272 && $0.endIndex == 431 && !$0.uri.isEmpty && $0.license == "mit"
959+
$0.startIndex == 899 && $0.endIndex == 1026 && !$0.uri.isEmpty && $0.license == ""
964960
}))
965961
}
966962

@@ -1159,7 +1155,7 @@ final class GenerativeModelTests: XCTestCase {
11591155

11601156
func testCountTokens_succeeds() async throws {
11611157
MockURLProtocol.requestHandler = try httpRequestHandler(
1162-
forResource: "success-total-tokens",
1158+
forResource: "unary-success-total-tokens",
11631159
withExtension: "json"
11641160
)
11651161

@@ -1171,7 +1167,7 @@ final class GenerativeModelTests: XCTestCase {
11711167

11721168
func testCountTokens_succeeds_noBillableCharacters() async throws {
11731169
MockURLProtocol.requestHandler = try httpRequestHandler(
1174-
forResource: "success-no-billable-characters",
1170+
forResource: "unary-success-no-billable-characters",
11751171
withExtension: "json"
11761172
)
11771173

@@ -1186,7 +1182,7 @@ final class GenerativeModelTests: XCTestCase {
11861182

11871183
func testCountTokens_modelNotFound() async throws {
11881184
MockURLProtocol.requestHandler = try httpRequestHandler(
1189-
forResource: "failure-model-not-found", withExtension: "json",
1185+
forResource: "unary-failure-model-not-found", withExtension: "json",
11901186
statusCode: 404
11911187
)
11921188

@@ -1207,7 +1203,7 @@ final class GenerativeModelTests: XCTestCase {
12071203
let expectedTimeout = 150.0
12081204
MockURLProtocol
12091205
.requestHandler = try httpRequestHandler(
1210-
forResource: "success-total-tokens",
1206+
forResource: "unary-success-total-tokens",
12111207
withExtension: "json",
12121208
timeout: expectedTimeout
12131209
)
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
data: {"candidates": [{"content": {},"index": 0}],"promptFeedback": {"safetyRatings": [{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE"}]}}
2+

0 commit comments

Comments
 (0)