From 691e4ba30113cee3508a54fd2383e34f38b55bde Mon Sep 17 00:00:00 2001 From: mo khan Date: Wed, 16 Apr 2025 15:13:01 -0600 Subject: feat: render a blank html page for the dashboard --- app/controllers/dashboard/controller.go | 39 ++++++++++++++++++++++++++++ app/controllers/dashboard/controller_test.go | 3 ++- test/integration/container_test.go | 2 +- 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/app/controllers/dashboard/controller.go b/app/controllers/dashboard/controller.go index cd1c44f..d805027 100644 --- a/app/controllers/dashboard/controller.go +++ b/app/controllers/dashboard/controller.go @@ -1,6 +1,7 @@ package dashboard import ( + "html/template" "net/http" "github.com/xlgmokha/x/pkg/context" @@ -31,4 +32,42 @@ func (c *Controller) Show(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) w.Header().Add("Content-Type", "text/html") + const tpl = ` + + + + + + + SparkleLab - {{.Title}} + + + +
+ + {{range .Sparkles}} +
{{ . }}
+ {{else}} +
No Sparkles
+ {{end}} +
+ +` + + t := x.Must(template.New("show").Parse(tpl)) + data := struct { + Title string + Sparkles []string + }{ + Title: "SparkleLab", + Sparkles: []string{}, + } + t.Execute(w, data) } diff --git a/app/controllers/dashboard/controller_test.go b/app/controllers/dashboard/controller_test.go index ac9e10d..ff2482f 100644 --- a/app/controllers/dashboard/controller_test.go +++ b/app/controllers/dashboard/controller_test.go @@ -4,9 +4,9 @@ import ( "net/http" "testing" + "github.com/stretchr/testify/assert" "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/domain" "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/test" - "gotest.tools/v3/assert" ) func TestController(t *testing.T) { @@ -35,6 +35,7 @@ func TestController(t *testing.T) { mux.ServeHTTP(w, r) assert.Equal(t, http.StatusOK, w.Code) assert.Equal(t, "text/html", w.Header().Get("Content-Type")) + assert.Contains(t, w.Body.String(), "