mirror of
https://github.com/datarhei/core.git
synced 2025-10-06 00:17:07 +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>
61 lines
1.1 KiB
Go
61 lines
1.1 KiB
Go
package api
|
|
|
|
import (
|
|
"bytes"
|
|
"encoding/json"
|
|
"net/http"
|
|
"testing"
|
|
|
|
"github.com/datarhei/core/v16/config"
|
|
"github.com/datarhei/core/v16/http/mock"
|
|
"github.com/labstack/echo/v4"
|
|
)
|
|
|
|
func getDummyConfigRouter() *echo.Echo {
|
|
router := mock.DummyEcho()
|
|
|
|
config := config.NewDummyStore()
|
|
|
|
handler := NewConfig(config)
|
|
|
|
router.Add("GET", "/", handler.Get)
|
|
router.Add("PUT", "/", handler.Set)
|
|
|
|
return router
|
|
}
|
|
|
|
func TestConfigGet(t *testing.T) {
|
|
router := getDummyConfigRouter()
|
|
|
|
mock.Request(t, http.StatusOK, router, "GET", "/", nil)
|
|
|
|
//validate(t, &api.RestreamerConfig{}, response.Data)
|
|
}
|
|
|
|
func TestConfigSetConflict(t *testing.T) {
|
|
router := getDummyConfigRouter()
|
|
|
|
var data bytes.Buffer
|
|
|
|
encoder := json.NewEncoder(&data)
|
|
encoder.Encode(config.New())
|
|
|
|
mock.Request(t, http.StatusConflict, router, "PUT", "/", &data)
|
|
}
|
|
|
|
func TestConfigSet(t *testing.T) {
|
|
router := getDummyConfigRouter()
|
|
|
|
var data bytes.Buffer
|
|
|
|
cfg := config.New()
|
|
cfg.DB.Dir = "."
|
|
cfg.Storage.Disk.Dir = "."
|
|
cfg.Storage.MimeTypes = ""
|
|
|
|
encoder := json.NewEncoder(&data)
|
|
encoder.Encode(cfg)
|
|
|
|
mock.Request(t, http.StatusOK, router, "PUT", "/", &data)
|
|
}
|