Skip to content

Commit

Permalink
AddDescription update and test
Browse files Browse the repository at this point in the history
  • Loading branch information
EwenQuim committed Dec 9, 2024
1 parent 63cf58a commit 1e6d931
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion option.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down
13 changes: 13 additions & 0 deletions option_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}

0 comments on commit 1e6d931

Please sign in to comment.