Skip to content

test: add coverage for mqtt/status date parsing#10

Open
augard wants to merge 1 commit intomainfrom
automation/test-gap-detection-2026-03-09
Open

test: add coverage for mqtt/status date parsing#10
augard wants to merge 1 commit intomainfrom
automation/test-gap-detection-2026-03-09

Conversation

@augard
Copy link
Owner

@augard augard commented Mar 9, 2026

Summary

  • add focused tests for millisecond timestamp parsing via DateValue<TimeIntervalDateFormatter>
  • add focused tests for compact merged timestamp parsing via DateValue<MergedDateFormatter>
  • add decode coverage for VehicleMQTTStatusResponse.latestUpdateTime + state mapping

Why

Recent MQTT/status integration changed timestamp handling paths without direct tests.

Verification

  • Added 3 focused XCTest cases in KiaTests/MockVehicleDataTests.swift
  • Full test run blocked in this environment previously by package/network constraints

@augard augard added codex Created by codex automation codex-automation Created by codex automation labels Mar 9, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2026

There is a problem with the Gemini CLI PR review. Please check the action logs for details.

@augard augard marked this pull request as ready for review March 9, 2026 09:19
Copilot AI review requested due to automatic review settings March 9, 2026 09:19
@augmentcode
Copy link

augmentcode bot commented Mar 9, 2026

🤖 Augment PR Summary

Summary: Adds focused XCTest coverage for MQTT/status timestamp parsing and response decoding.

Changes: (1) Test millisecond-epoch string decoding via DateValue<TimeIntervalDateFormatter>.

(2) Test compact yyyyMMddHHmmss decoding via DateValue<MergedDateFormatter>.

(3) Add decode coverage for VehicleMQTTStatusResponse including latestUpdateTime key mapping.

Why: Protect recent timestamp-handling changes with direct unit tests.

Notes: Keeps tests small/isolated to avoid needing full integration/network setup.

🤖 Was this summary useful? React with 👍 or 👎

Copy link

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 1 suggestion posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

components.minute = 25
components.second = 13
components.timeZone = TimeZone(secondsFromGMT: 0)
let expected = Calendar(identifier: .gregorian).date(from: components)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 VehicleMQTTStatusResponse payload 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)
)

Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
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)

Copilot uses AI. Check for mistakes.
components.minute = 25
components.second = 13
components.timeZone = TimeZone(secondsFromGMT: 0)
let expected = Calendar(identifier: .gregorian).date(from: components)
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
let expected = Calendar(identifier: .gregorian).date(from: components)
let expected = try XCTUnwrap(Calendar(identifier: .gregorian).date(from: components))

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codex Created by codex automation codex-automation Created by codex automation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants