forked from akvorado/akvorado
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhttp_test.go
67 lines (62 loc) · 1.68 KB
/
http_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// SPDX-FileCopyrightText: 2022 Free Mobile
// SPDX-License-Identifier: AGPL-3.0-only
package orchestrator
import (
"testing"
"akvorado/common/helpers"
"akvorado/common/http"
"akvorado/common/reporter"
)
func TestConfigurationEndpoint(t *testing.T) {
r := reporter.NewMock(t)
h := http.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/x-yaml; charset=utf-8",
FirstLines: []string{
`bye: Goodbye world!`,
`hello: Hello world!`,
},
}, {
URL: "/api/v0/orchestrator/configuration/inlet/0",
ContentType: "application/x-yaml; charset=utf-8",
FirstLines: []string{
`bye: Goodbye world!`,
`hello: Hello world!`,
},
}, {
URL: "/api/v0/orchestrator/configuration/inlet/1",
ContentType: "application/x-yaml; charset=utf-8",
FirstLines: []string{
`bye: Goodbye pal!`,
`hello: Hello pal!`,
},
}, {
URL: "/api/v0/orchestrator/configuration/inlet/2",
ContentType: "application/x-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,
},
})
}