Go-based FM stereo transmitter with RDS, Windows-first and cross-platform
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

38 řádky
1011B

  1. package control
  2. import (
  3. "encoding/json"
  4. "net/http"
  5. "net/http/httptest"
  6. "testing"
  7. cfgpkg "github.com/jan/fm-rds-tx/internal/config"
  8. )
  9. func TestHealthz(t *testing.T) {
  10. srv := NewServer(cfgpkg.Default())
  11. req := httptest.NewRequest(http.MethodGet, "/healthz", nil)
  12. rec := httptest.NewRecorder()
  13. srv.Handler().ServeHTTP(rec, req)
  14. if rec.Code != http.StatusOK {
  15. t.Fatalf("unexpected status: %d", rec.Code)
  16. }
  17. }
  18. func TestStatus(t *testing.T) {
  19. srv := NewServer(cfgpkg.Default())
  20. req := httptest.NewRequest(http.MethodGet, "/status", nil)
  21. rec := httptest.NewRecorder()
  22. srv.Handler().ServeHTTP(rec, req)
  23. if rec.Code != http.StatusOK {
  24. t.Fatalf("unexpected status: %d", rec.Code)
  25. }
  26. var body map[string]any
  27. if err := json.Unmarshal(rec.Body.Bytes(), &body); err != nil {
  28. t.Fatalf("decode body: %v", err)
  29. }
  30. if body["service"] != "fm-rds-tx" {
  31. t.Fatalf("unexpected service: %v", body["service"])
  32. }
  33. }