package com.cameleer.server.app.controller;

import com.cameleer.server.app.AbstractPostgresIT;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.web.client.TestRestTemplate;

import static org.assertj.core.api.Assertions.assertThat;

/**
 * Integration tests for the health endpoint.
 */
class HealthControllerIT extends AbstractPostgresIT {

    @Autowired
    private TestRestTemplate restTemplate;

    @Test
    void healthEndpointReturns200WithStatus() {
        var response = restTemplate.getForEntity("/api/v1/health", String.class);
        assertThat(response.getStatusCode().value()).isEqualTo(200);
        assertThat(response.getBody()).contains("status");
    }

    @Test
    void healthEndpointDoesNotRequireProtocolVersionHeader() {
        // Health should be accessible without X-Cameleer-Protocol-Version header
        var response = restTemplate.getForEntity("/api/v1/health", String.class);
        assertThat(response.getStatusCode().value()).isEqualTo(200);
    }
}
