Skip to content

Commit

Permalink
unit test for common params
Browse files Browse the repository at this point in the history
  • Loading branch information
reuvenharrison committed Feb 23, 2025
1 parent 678cf1c commit 73821b8
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions flatten/commonparams/params_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package commonparams_test

import (
"net/http"
"testing"

"github.com/getkin/kin-openapi/openapi3"
"github.com/stretchr/testify/require"
"github.com/tufin/oasdiff/flatten/commonparams"
)

func TestMove(t *testing.T) {
spec := &openapi3.T{}
spec.Paths = openapi3.NewPathsWithCapacity(1)
spec.Paths.Set("/path", &openapi3.PathItem{
Parameters: openapi3.Parameters{
&openapi3.ParameterRef{
Value: &openapi3.Parameter{
Name: "X-Header",
In: "query",
},
},
},
})
spec.Paths.Find("/path").SetOperation(http.MethodGet, &openapi3.Operation{})

commonparams.Move(spec)

require.Empty(t, spec.Paths.Find("/path").Parameters.GetByInAndName("query", "X-Header"))
require.NotEmpty(t, spec.Paths.Find("/path").Get.Parameters.GetByInAndName("query", "X-Header"))
}

0 comments on commit 73821b8

Please sign in to comment.