Conversation
|
There is a problem with the Gemini CLI PR review. Please check the action logs for details. |
🤖 Augment PR SummarySummary: Adds focused XCTest coverage for MQTT/status timestamp parsing and response decoding. 🤖 Was this summary useful? React with 👍 or 👎 |
| components.minute = 25 | ||
| components.second = 13 | ||
| components.timeZone = TimeZone(secondsFromGMT: 0) | ||
| let expected = Calendar(identifier: .gregorian).date(from: components) |
There was a problem hiding this comment.
Calendar(identifier: .gregorian).date(from:) returns an optional Date; consider unwrapping the result so the test fails loudly if the components can’t be converted and the subsequent equality check is against a non-optional value.
Severity: medium
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
There was a problem hiding this comment.
Pull request overview
Adds targeted XCTest coverage around the recent MQTT/status timestamp parsing changes and related decoding paths in the KiaMaps API model layer.
Changes:
- Add a unit test validating millisecond-epoch timestamp string decoding via
@DateValue<TimeIntervalDateFormatter>. - Add a unit test validating compact UTC timestamp decoding via
@DateValue<MergedDateFormatter>. - Add a decode test exercising
VehicleMQTTStatusResponsepayload decoding and basic state mapping.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| VehicleMQTTStatusResponse.self, | ||
| from: Data(mqttJSON.utf8) | ||
| ) | ||
|
|
There was a problem hiding this comment.
testVehicleMQTTStatusResponseDecodesLatestUpdateTimeAndState doesn’t currently assert anything about latestUpdateTime/lastUpdateTime, so it won’t catch regressions in the CodingKeys mapping or MergedDateFormatter parsing. Add an assertion that response.lastUpdateTime matches the expected UTC date represented by "20250901202513" (or rename the test if time decoding is intentionally out of scope).
| var components = DateComponents() | |
| components.year = 2025 | |
| components.month = 9 | |
| components.day = 1 | |
| components.hour = 20 | |
| components.minute = 25 | |
| components.second = 13 | |
| components.timeZone = TimeZone(secondsFromGMT: 0) | |
| let expected = Calendar(identifier: .gregorian).date(from: components) | |
| XCTAssertEqual(response.lastUpdateTime, expected) |
| components.minute = 25 | ||
| components.second = 13 | ||
| components.timeZone = TimeZone(secondsFromGMT: 0) | ||
| let expected = Calendar(identifier: .gregorian).date(from: components) |
There was a problem hiding this comment.
expected is a Date? from Calendar.date(from:); if it were ever nil, the assertion failure would be less clear. Consider unwrapping with XCTUnwrap (or assert not-nil) before comparing to payload.latestUpdateTime so failures point to calendar construction vs decoding.
| let expected = Calendar(identifier: .gregorian).date(from: components) | |
| let expected = try XCTUnwrap(Calendar(identifier: .gregorian).date(from: components)) |
Summary
DateValue<TimeIntervalDateFormatter>DateValue<MergedDateFormatter>VehicleMQTTStatusResponse.latestUpdateTime+ state mappingWhy
Recent MQTT/status integration changed timestamp handling paths without direct tests.
Verification
KiaTests/MockVehicleDataTests.swift