Test: add full payload JSON round-trip test in SystemStatusTests - #2221
Test: add full payload JSON round-trip test in SystemStatusTests#2221denizguney wants to merge 6 commits into
Conversation
Adds a new unit test to verify that system status payloads with nested paths and resource counts correctly round-trip through JSON encoding and decoding.
| let decoded = try JSONDecoder().decode(Application.StatusPayload.self, from: Data(json.utf8)) | ||
|
|
||
| #expect(decoded.paths?.appRoot == "/app") | ||
| #expect(decoded.resources?.containersTotal == 10) |
There was a problem hiding this comment.
@denizguney This seems quite specific. Is it provable that these values will hold under all conditions?
There was a problem hiding this comment.
You're right, these values are currently specific to this sample test payload. Our main goal here is to isolate and verify the correct parsing and type safety of the StatusPayload structure. However, I can make the test more robust or document that this is strictly a deterministic validation for this specific mock fixture. Let me know if you'd prefer a more dynamic approach or if adjusting the fixture assertions works best!"
There was a problem hiding this comment.
Nah, I got it wrong. I thought I was looking at CLI tests. This test looks fine, please just fix the little whitespace nit and we can merge it.
There was a problem hiding this comment.
Fixed the whitespace nit. Thanks for the review
| let updated = Application.SystemStatus.withImageCount(resources, imageCount: nil) | ||
| #expect(updated?.images == nil) | ||
| } | ||
| @Test |
There was a problem hiding this comment.
nit: add one line of white space
| let decoded = try JSONDecoder().decode(Application.StatusPayload.self, from: Data(json.utf8)) | ||
|
|
||
| #expect(decoded.paths?.appRoot == "/app") | ||
| #expect(decoded.resources?.containersTotal == 10) |
There was a problem hiding this comment.
Nah, I got it wrong. I thought I was looking at CLI tests. This test looks fine, please just fix the little whitespace nit and we can merge it.
Add missing whitespace before the test method as requested in the review nit.
denizguney
left a comment
There was a problem hiding this comment.
Fixed the requested whitespace nit. Thanks again for the review
| let decoded = try JSONDecoder().decode(Application.StatusPayload.self, from: Data(json.utf8)) | ||
|
|
||
| #expect(decoded.paths?.appRoot == "/app") | ||
| #expect(decoded.resources?.containersTotal == 10) |
There was a problem hiding this comment.
Fixed the whitespace nit. Thanks for the review
|
@denizguney you'll need a |
|
"Fixed! Thanks for the review." |
Code Coverage
|
Adds a new unit test to verify that system status payloads with nested paths and resource counts correctly round-trip through JSON encoding and decoding.
Type of Change
Motivation and Context
Adds comprehensive JSON round-trip unit test coverage for SystemStatusTests to ensure correct encoding/decoding of nested paths and resource counts.
Testing