Files
canada-kaktus/internal/health_test.go
Julian 4aa8d104bb
All checks were successful
Gitea Docker Build Demo / Test (push) Successful in 3m20s
Gitea Docker Build Demo / Build_Image (push) Successful in 1m25s
add goSec, go-lint, update actions (#2)
Co-authored-by: Julian <j-ha+gitea@uploadfilter24.eu>
Co-committed-by: Julian <j-ha+gitea@uploadfilter24.eu>
2025-10-09 15:47:40 +00:00

31 lines
623 B
Go

package internal
import (
"net/http"
"strings"
"testing"
"time"
)
func TestHealth(t *testing.T) {
hs := NewHealthServer()
go func() {
hs.Start()
}()
// Give the server time to start up
time.Sleep(100 * time.Millisecond)
request, _ := http.NewRequest(http.MethodGet, "http://localhost:8080/health", strings.NewReader(""))
resp, err := http.DefaultClient.Do(request)
if err != nil {
t.Errorf("Health endpoint did not start: %v", err)
return
}
if resp != nil && resp.StatusCode != http.StatusOK {
t.Errorf("Bad response from health endpoint. Want: %d, got %d", http.StatusOK, resp.StatusCode)
}
}