25 lines
593 B
Go
25 lines
593 B
Go
package server
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
// TestHealthCheck verifies the health endpoint returns database status
|
|
func TestHealthCheck(t *testing.T) {
|
|
e := StartTestServer(t)
|
|
// No explicit teardown - handled by StartTestServer's sync.Once
|
|
|
|
resp := MakeTestRequest(t, e, "GET", "/health")
|
|
assert.Equal(t, http.StatusOK, resp.Code)
|
|
|
|
var healthData map[string]string
|
|
err := json.Unmarshal(resp.Body.Bytes(), &healthData)
|
|
assert.NoError(t, err)
|
|
assert.NotEmpty(t, healthData)
|
|
assert.Equal(t, "up", healthData["status"])
|
|
}
|