From 1e6d931908a80d221917894b9b3dfdc222279c88 Mon Sep 17 00:00:00 2001 From: EwenQuim Date: Mon, 9 Dec 2024 15:17:08 +0100 Subject: [PATCH] AddDescription update and test --- option.go | 2 +- option_test.go | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/option.go b/option.go index dfa0cf85..7f2a72df 100644 --- a/option.go +++ b/option.go @@ -225,7 +225,7 @@ func OptionDescription(description string) func(*BaseRoute) { // like the controller function name and the package name. func OptionAddDescription(description string) func(*BaseRoute) { return func(r *BaseRoute) { - r.Operation.Description += description + r.Operation.Description += "\n\n" + description } } diff --git a/option_test.go b/option_test.go index 21244f84..600d628e 100644 --- a/option_test.go +++ b/option_test.go @@ -682,3 +682,16 @@ func TestSecurity(t *testing.T) { require.Equal(t, []string{"basic"}, security["ApiKey"]) }) } + +func TestOptionAddDescription(t *testing.T) { + t.Run("Declare a description for the route with multiple descriptions", func(t *testing.T) { + s := fuego.NewServer() + + route := fuego.Get(s, "/test", helloWorld, + fuego.OptionDescription("test description"), + fuego.OptionAddDescription("another description"), + ) + + require.Equal(t, "controller: `github.com/go-fuego/fuego_test.helloWorld`\n\n---\n\ntest description\n\nanother description", route.Operation.Description) + }) +}