mirror of
https://github.com/akvorado/akvorado.git
synced 2025-12-12 06:24:10 +01:00
global: split Akvorado into 3 services
This commit is contained in:
48
console/docs_test.go
Normal file
48
console/docs_test.go
Normal file
@@ -0,0 +1,48 @@
|
||||
package console
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
netHTTP "net/http"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"akvorado/common/daemon"
|
||||
"akvorado/common/http"
|
||||
"akvorado/common/reporter"
|
||||
)
|
||||
|
||||
func TestServeDocs(t *testing.T) {
|
||||
for _, live := range []bool{false, true} {
|
||||
name := "livefs"
|
||||
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)
|
||||
}
|
||||
|
||||
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")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user