Files
core/http/handler/api/config_test.go
Jan Stabenow eb1cc37456 Add GoSRT & improvements (repo-merge)
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>
2022-06-23 22:13:58 +02:00

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)
}