Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Tests/ContainerCommandsTests/SystemStatusTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,17 @@ 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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The 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!"

#expect(decoded.resources?.containersRunning == 4)
}
}