-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Test: add full payload JSON round-trip test in SystemStatusTests #2221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
bc00cce
19e25a1
cbaf690
2e32144
f04d598
a4bb1d5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -110,4 +110,18 @@ struct SystemStatusTests { | |
| let updated = Application.SystemStatus.withImageCount(resources, imageCount: nil) | ||
| #expect(updated?.images == nil) | ||
| } | ||
|
|
||
| @Test | ||
| func fullPayloadRoundTripsThroughJSON() throws { | ||
| let payload = makeRunningPayload( | ||
| paths: Application.PathInfo(appRoot: "/app", installRoot: "/install", logRoot: "/log"), | ||
| resources: Application.ResourceCounts(containersTotal: 10, containersRunning: 4) | ||
| ) | ||
| let json = try Output.renderJSON(payload) | ||
| let decoded = try JSONDecoder().decode(Application.StatusPayload.self, from: Data(json.utf8)) | ||
|
|
||
| #expect(decoded.paths?.appRoot == "/app") | ||
| #expect(decoded.resources?.containersTotal == 10) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @denizguney This seems quite specific. Is it provable that these values will hold under all conditions?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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!"
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed the whitespace nit. Thanks for the review |
||
| #expect(decoded.resources?.containersRunning == 4) | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: add one line of white space