Files
akvorado/orchestrator/http_test.go
dependabot[bot] 17d9a6b6de build: bump github.com/gin-gonic/gin from 1.9.1 to 1.10.0
Also update YAML MIME type.
2024-05-21 07:54:55 +02:00

68 lines
1.7 KiB
Go

// SPDX-FileCopyrightText: 2022 Free Mobile
// SPDX-License-Identifier: AGPL-3.0-only
package orchestrator
import (
"testing"
"akvorado/common/helpers"
"akvorado/common/httpserver"
"akvorado/common/reporter"
)
func TestConfigurationEndpoint(t *testing.T) {
r := reporter.NewMock(t)
h := httpserver.NewMock(t, r)
c, err := New(r, DefaultConfiguration(), Dependencies{
HTTP: h,
})
if err != nil {
t.Fatalf("New() error:\n%+v", err)
}
c.RegisterConfiguration(InletService, map[string]string{
"hello": "Hello world!",
"bye": "Goodbye world!",
})
c.RegisterConfiguration(InletService, map[string]string{
"hello": "Hello pal!",
"bye": "Goodbye pal!",
})
helpers.TestHTTPEndpoints(t, h.LocalAddr(), helpers.HTTPEndpointCases{
{
URL: "/api/v0/orchestrator/configuration/inlet",
ContentType: "application/yaml; charset=utf-8",
FirstLines: []string{
`bye: Goodbye world!`,
`hello: Hello world!`,
},
}, {
URL: "/api/v0/orchestrator/configuration/inlet/0",
ContentType: "application/yaml; charset=utf-8",
FirstLines: []string{
`bye: Goodbye world!`,
`hello: Hello world!`,
},
}, {
URL: "/api/v0/orchestrator/configuration/inlet/1",
ContentType: "application/yaml; charset=utf-8",
FirstLines: []string{
`bye: Goodbye pal!`,
`hello: Hello pal!`,
},
}, {
URL: "/api/v0/orchestrator/configuration/inlet/2",
ContentType: "application/yaml; charset=utf-8",
FirstLines: []string{
`bye: Goodbye world!`,
`hello: Hello world!`,
},
}, {
URL: "/api/v0/orchestrator/configuration/console/0",
ContentType: "application/json; charset=utf-8",
StatusCode: 404,
},
})
}