mirror of
https://github.com/datarhei/core.git
synced 2025-09-27 04:16:25 +08:00

Commits (Ingo Oppermann): - Add experimental SRT connection stats and logs - Hide /config/reload endpoint in reade-only mode - Add SRT server - Create v16 in go.mod - Fix data races, tests, lint, and update dependencies - Add trailing slash for routed directories (datarhei/restreamer#340) - Allow relative URLs in content in static routes Co-Authored-By: Ingo Oppermann <57445+ioppermann@users.noreply.github.com>
46 lines
1.0 KiB
Go
46 lines
1.0 KiB
Go
package api
|
|
|
|
import (
|
|
"net/http"
|
|
"testing"
|
|
|
|
"github.com/datarhei/core/v16/http/api"
|
|
"github.com/datarhei/core/v16/http/mock"
|
|
"github.com/datarhei/core/v16/session"
|
|
|
|
"github.com/labstack/echo/v4"
|
|
)
|
|
|
|
func getDummySessionRouter() *echo.Echo {
|
|
router := mock.DummyEcho()
|
|
|
|
registry, _ := session.New(session.Config{})
|
|
registry.Register("foo", session.CollectorConfig{})
|
|
|
|
collector := registry.Collector("foo")
|
|
collector.RegisterAndActivate("foobar", "", "any", "any")
|
|
|
|
handler := NewSession(registry)
|
|
|
|
router.Add("GET", "/summary", handler.Summary)
|
|
router.Add("GET", "/active", handler.Active)
|
|
|
|
return router
|
|
}
|
|
|
|
func TestSessionSummary(t *testing.T) {
|
|
router := getDummySessionRouter()
|
|
|
|
response := mock.Request(t, http.StatusOK, router, "GET", "/summary?collectors=foo", nil)
|
|
|
|
mock.Validate(t, api.SessionsSummary{}, response.Data)
|
|
}
|
|
|
|
func TestSessionActive(t *testing.T) {
|
|
router := getDummySessionRouter()
|
|
|
|
response := mock.Request(t, http.StatusOK, router, "GET", "/active?collectors=foo", nil)
|
|
|
|
mock.Validate(t, api.SessionsActive{}, response.Data)
|
|
}
|