package com.correx.apps.cli.commands

import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test

class HealthRenderTest {

    @Test
    fun `render shows overall and each subject row`() {
        val report = HealthReportDto(
            overall = "DEGRADED",
            subjects = listOf(
                HealthSubjectReportDto(
                    subject = "DISK",
                    status = "DEGRADED",
                    metric = "total_bytes",
                    observedValue = 6_000_000_000,
                    detail = "event log + CAS at 5.6 GiB (warn ≥ 4.7 GiB)",
                    since = "2026-06-13T01:00:00Z",
                ),
            ),
            checkedAt = "2026-06-13T02:00:00Z",
        )
        val out = renderHealth(report)
        assertTrue(out.contains("Overall:   DEGRADED"), "overall missing")
        assertTrue(out.contains("DISK"), "subject row missing")
        assertTrue(out.contains("5.6 GiB"), "detail missing")
        assertTrue(out.contains("since 2026-06-13T01:00:00Z"), "since line missing")
    }

    @Test
    fun `render handles the empty no-checks case`() {
        val out = renderHealth(HealthReportDto(overall = "HEALTHY"))
        assertTrue(out.contains("Overall:   HEALTHY"))
        assertTrue(out.contains("No health checks recorded yet."), "empty hint missing")
    }
}
