Skip to content

Add Unity unit tests for RuntimeConfig parsing and validation #14

Description

@TalkingJupiter

Context

parseRuntimeConfigJson() is the choke point every host config flows through, and it currently has zero coverage. It is also the place where the #6 validation gap and the #11 schema decisions live — writing these tests forces both.

Scope

On-device Unity tests under ESP32-Firmware/test/test_runtime_config/, run with pio test -e esp32_a over USB. On-device (not native) because RuntimeConfig uses Arduino String; native execution would need ArduinoFake or a std::string refactor, which is not worth it yet.

Test cases

  • Valid full config → accepted, every field populated in the struct
  • Garbage / truncated JSON → rejected, parse error in err
  • message_type != "config" → rejected
  • configured: false → rejected with "Device is not configured"
  • enabled: false → rejected — documents the current remote-disable dead end; this test's expectation flips when Fix RuntimeConfig validation for required topics #6 is fixed
  • Missing rack_id → rejected
  • role: "controllerA" → rejected as Unknown — codifies the role-vocabulary decision from Align config schema between firmware and host provisioning example #11
  • Missing topics.telemetrycurrently passes validation, should fail — write it expecting failure, watch it fail, fix isValid(), watch it pass (this is the Fix RuntimeConfig validation for required topics #6 bug, test-first)
  • parseRole / roleToString round-trip for Primary, Standby, Unknown

Acceptance criteria

Relates to #6, #11.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions