@@ -20,6 +20,7 @@ import (
2020
2121 "github.com/getkin/kin-openapi/openapi3"
2222 "github.com/mongodb/openapi/tools/cli/internal/pointer"
23+ "github.com/stretchr/testify/assert"
2324 "github.com/stretchr/testify/require"
2425 "github.com/tufin/oasdiff/diff"
2526 "github.com/tufin/oasdiff/load"
@@ -143,13 +144,18 @@ func TestOasDiff_mergeTags(t *testing.T) {
143144 inputExternal * load.SpecInfo
144145 wantErr require.ErrorAssertionFunc
145146 name string
147+ expectedTags []* openapi3.Tag
146148 }{
147149 {
148150 name : "SuccessfulMerge" ,
149151 inputBase : & load.SpecInfo {
150152 Url : "base" ,
151153 Spec : & openapi3.T {
152154 Tags : []* openapi3.Tag {
155+ {
156+ Name : "TagBase3" ,
157+ Description : "TagBase3" ,
158+ },
153159 {
154160 Name : "TagBase1" ,
155161 Description : "TagBase1" ,
@@ -181,6 +187,30 @@ func TestOasDiff_mergeTags(t *testing.T) {
181187 Version : "3.0.1" ,
182188 },
183189 wantErr : require .NoError ,
190+ expectedTags : []* openapi3.Tag {
191+ {
192+ Name : "Tag1" ,
193+ Description : "Tag1" ,
194+ },
195+
196+ {
197+ Name : "Tag2" ,
198+ Description : "Tag2" ,
199+ },
200+ {
201+ Name : "TagBase1" ,
202+ Description : "TagBase1" ,
203+ },
204+
205+ {
206+ Name : "TagBase2" ,
207+ Description : "TagBase2" ,
208+ },
209+ {
210+ Name : "TagBase3" ,
211+ Description : "TagBase3" ,
212+ },
213+ },
184214 },
185215 {
186216 name : "SuccessfulMergeEmptyTags" ,
@@ -305,6 +335,13 @@ func TestOasDiff_mergeTags(t *testing.T) {
305335 external : tc .inputExternal ,
306336 }
307337 tc .wantErr (t , o .mergeTags ())
338+ if tc .expectedTags != nil {
339+ assert .Equal (t , len (o .base .Spec .Tags ), len (tc .expectedTags ))
340+ // check tag names are the same
341+ for i := range o .base .Spec .Tags {
342+ assert .Equal (t , o .base .Spec .Tags [i ].Name , tc .expectedTags [i ].Name )
343+ }
344+ }
308345 })
309346 }
310347}
0 commit comments