Skip to content

Commit

Permalink
Merge pull request #18 from TianTianBigWang/me-main
Browse files Browse the repository at this point in the history
improve test coverage for addDefinition
  • Loading branch information
zc2638 authored Nov 22, 2022
2 parents 7004ccb + 634994a commit 8b70bac
Showing 1 changed file with 60 additions and 4 deletions.
64 changes: 60 additions & 4 deletions api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (
"strings"
"testing"

"github.com/zc2638/swag/types"

"github.com/stretchr/testify/assert"
)

Expand Down Expand Up @@ -645,8 +647,59 @@ func TestAPI_AddEndpoint(t *testing.T) {
Method: http.MethodGet,
Summary: "summary",
Description: "desc",
Parameters: nil,
Responses: nil,
Parameters: []Parameter{
{
Schema: MakeSchema(types.String),
},
},
Responses: map[string]Response{
"string": {
Schema: MakeSchema(types.String),
},
},
},
},
},
want: API{
Paths: map[string]*Endpoints{
"/test": {
Get: &Endpoint{
Tags: []string{"tag1"},
Path: "/test",
Method: http.MethodGet,
Summary: "summary",
Description: "desc",
OperationID: "getTest",
Parameters: []Parameter{
{
Schema: MakeSchema(types.String),
},
},
Responses: map[string]Response{
"string": {
Schema: MakeSchema(types.String),
},
},
},
},
},
},
},
{
name: "normal-withResponse",
args: args{
es: []*Endpoint{
{
Tags: nil,
Path: "/test",
Method: http.MethodGet,
Summary: "summary",
Description: "desc",
Responses: map[string]Response{
"string": {
Schema: MakeSchema(types.String),
},
},
},
},
},
Expand All @@ -660,8 +713,11 @@ func TestAPI_AddEndpoint(t *testing.T) {
Summary: "summary",
Description: "desc",
OperationID: "getTest",
Parameters: nil,
Responses: nil,
Responses: map[string]Response{
"string": {
Schema: MakeSchema(types.String),
},
},
},
},
},
Expand Down

0 comments on commit 8b70bac

Please sign in to comment.