Files
core/http/handler/api/session_test.go
Jan Stabenow 9c0b535199 Add v16.7.2
2022-05-13 19:26:45 +02:00

46 lines
1.0 KiB
Go

package api
import (
"net/http"
"testing"
"github.com/datarhei/core/http/api"
"github.com/datarhei/core/http/mock"
"github.com/datarhei/core/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)
}