From d9a9a9071d16c779a390d94666f736e1e96c48dc Mon Sep 17 00:00:00 2001 From: Maria Date: Tue, 21 May 2024 19:09:28 +0100 Subject: feat: Allow packages to define custom documentation URL and badge (#147) feat: Allow packages to define custom doc URL and badge Co-authored-by: Jacob Oaks Co-authored-by: r-hang --- handler_test.go | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'handler_test.go') diff --git a/handler_test.go b/handler_test.go index c88fe9d..5cee564 100644 --- a/handler_test.go +++ b/handler_test.go @@ -28,6 +28,10 @@ packages: repo: github.com/yarpc/metrics net/something: repo: github.com/yarpc/something + scago: + repo: github.com/m5ka/scago + doc_url: https://example.org/docs/go-pkg/scago + doc_badge: https://img.shields.io/badge/custom_docs-scago-blue?logo=go ` @@ -41,6 +45,7 @@ func TestIndex(t *testing.T) { assert.Contains(t, body, "A fast, structured logging library.") assert.Contains(t, body, "github.com/yarpc/metrics") assert.Contains(t, body, "github.com/yarpc/something") + assert.Contains(t, body, "github.com/m5ka/scago") } func TestSubindex(t *testing.T) { @@ -49,6 +54,7 @@ func TestSubindex(t *testing.T) { body := rr.Body.String() assert.NotContains(t, body, "github.com/thriftrw/thriftrw-go") + assert.NotContains(t, body, "github.com/m5ka/scago") assert.NotContains(t, body, "github.com/yarpc/yarpc-go") assert.Contains(t, body, "github.com/yarpc/metrics") assert.Contains(t, body, "github.com/yarpc/something") @@ -189,6 +195,41 @@ func TestPackageLevelURL(t *testing.T) { `) } +func TestCustomDocURL(t *testing.T) { + rr := CallAndRecord(t, config, getTestTemplates(t, nil), "/scago") + AssertResponse(t, rr, 200, ` + + + + + + + + + Nothing to see here. Please move along. + + +`) +} + +func TestCustomDocBadge(t *testing.T) { + rr := CallAndRecord(t, config, getTestTemplates(t, nil), "/") + assert.Equal(t, 200, rr.Code) + + body := rr.Body.String() + assert.Contains(t, body, "\"Go") + assert.Contains(t, body, "\"Go") + assert.Contains(t, body, + "\"Go") + assert.NotContains(t, body, "\"Go") +} + func TestPostRejected(t *testing.T) { t.Parallel() -- cgit v1.2.3