Skip to content

Commit 1e4479e

Browse files
committed
test: add openapi3/operation_test
1 parent f0a0d09 commit 1e4479e

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

openapi3/operation_test.go

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package openapi3
2+
3+
import (
4+
"testing"
5+
"github.com/stretchr/testify/require"
6+
)
7+
8+
var operation *Operation
9+
10+
func initOperation() {
11+
operation = NewOperation()
12+
operation.Description = "Some description"
13+
operation.Summary = "Some summary"
14+
operation.Tags = []string{"tag1", "tag2"}
15+
}
16+
17+
func TestAddParameter(t *testing.T) {
18+
initOperation()
19+
operation.AddParameter(NewQueryParameter("param1"))
20+
operation.AddParameter(NewCookieParameter("param2"))
21+
require.Equal(t, "param1", operation.Parameters.GetByInAndName("query", "param1").Name)
22+
require.Equal(t, "param2", operation.Parameters.GetByInAndName("cookie", "param2").Name)
23+
}
24+
25+
func TestAddResponse(t *testing.T) {
26+
initOperation()
27+
operation.AddResponse(200, NewResponse())
28+
operation.AddResponse(400, NewResponse())
29+
require.NotNil(t, "status 200", operation.Responses.Get(200).Value)
30+
require.NotNil(t, "status 400", operation.Responses.Get(400).Value)
31+
}

0 commit comments

Comments
 (0)