mirror of
https://github.com/akvorado/akvorado.git
synced 2025-12-11 22:14:02 +01:00
console: switch to Vue.JS + Tailwind CSS + Headless UI for the frontend
This commit is contained in:
@@ -7,7 +7,6 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"akvorado/common/daemon"
|
||||
"akvorado/common/http"
|
||||
"akvorado/common/reporter"
|
||||
)
|
||||
@@ -18,31 +17,42 @@ func TestServeDocs(t *testing.T) {
|
||||
if !live {
|
||||
name = "embeddedfs"
|
||||
}
|
||||
t.Run(name, func(t *testing.T) {
|
||||
r := reporter.NewMock(t)
|
||||
h := http.NewMock(t, r)
|
||||
_, err := New(r, Configuration{
|
||||
ServeLiveFS: live,
|
||||
}, Dependencies{
|
||||
HTTP: h,
|
||||
Daemon: daemon.NewMock(t),
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("New() error:\n%+v", err)
|
||||
}
|
||||
cases := []struct {
|
||||
Path string
|
||||
Expect string
|
||||
}{
|
||||
{"usage", `<a href=\"configuration\">configuration section</a>`},
|
||||
{"intro", `data:image/svg`},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
t.Run(fmt.Sprintf("%s-%s", name, tc.Path), func(t *testing.T) {
|
||||
r := reporter.NewMock(t)
|
||||
h := http.NewMock(t, r)
|
||||
_, err := New(r, Configuration{
|
||||
ServeLiveFS: live,
|
||||
}, Dependencies{
|
||||
HTTP: h,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("New() error:\n%+v", err)
|
||||
}
|
||||
|
||||
resp, err := netHTTP.Get(fmt.Sprintf("http://%s/docs/usage", h.Address))
|
||||
if err != nil {
|
||||
t.Fatalf("GET /docs/usage:\n%+v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
if resp.StatusCode != 200 {
|
||||
t.Errorf("GET /docs/usage: got status code %d, not 200", resp.StatusCode)
|
||||
}
|
||||
body, _ := ioutil.ReadAll(resp.Body)
|
||||
if strings.Contains(string(body), "configuration.md") {
|
||||
t.Errorf("GET /docs/usage: contains %q while it should not", "configuration.md")
|
||||
}
|
||||
})
|
||||
resp, err := netHTTP.Get(fmt.Sprintf("http://%s/api/v0/docs/%s",
|
||||
h.Address, tc.Path))
|
||||
if err != nil {
|
||||
t.Fatalf("GET /api/v0/docs/%s:\n%+v", tc.Path, err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
if resp.StatusCode != 200 {
|
||||
t.Errorf("GET /api/v0/docs/%s: got status code %d, not 200",
|
||||
tc.Path, resp.StatusCode)
|
||||
}
|
||||
body, _ := ioutil.ReadAll(resp.Body)
|
||||
if !strings.Contains(string(body), tc.Expect) {
|
||||
t.Errorf("GET /api/v0/docs/%s: does not contain %q",
|
||||
tc.Path, tc.Expect)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user