(t *testing.T)
| 8 | ) |
| 9 | |
| 10 | func TestFindReferences(t *testing.T) { |
| 11 | t.Run("unfiltered", func(t *testing.T) { |
| 12 | swagger, err := openapi3.NewLoader().LoadFromData([]byte(pruneSpecTestFixture)) |
| 13 | assert.NoError(t, err) |
| 14 | |
| 15 | refs := findComponentRefs(swagger) |
| 16 | assert.Len(t, refs, 14) |
| 17 | }) |
| 18 | t.Run("only cat", func(t *testing.T) { |
| 19 | swagger, err := openapi3.NewLoader().LoadFromData([]byte(pruneSpecTestFixture)) |
| 20 | assert.NoError(t, err) |
| 21 | opts := Configuration{ |
| 22 | OutputOptions: OutputOptions{ |
| 23 | IncludeTags: []string{"cat"}, |
| 24 | }, |
| 25 | } |
| 26 | |
| 27 | filterOperationsByTag(swagger, opts) |
| 28 | |
| 29 | refs := findComponentRefs(swagger) |
| 30 | assert.Len(t, refs, 7) |
| 31 | }) |
| 32 | t.Run("only dog", func(t *testing.T) { |
| 33 | swagger, err := openapi3.NewLoader().LoadFromData([]byte(pruneSpecTestFixture)) |
| 34 | assert.NoError(t, err) |
| 35 | |
| 36 | opts := Configuration{ |
| 37 | OutputOptions: OutputOptions{ |
| 38 | IncludeTags: []string{"dog"}, |
| 39 | }, |
| 40 | } |
| 41 | |
| 42 | filterOperationsByTag(swagger, opts) |
| 43 | |
| 44 | refs := findComponentRefs(swagger) |
| 45 | assert.Len(t, refs, 7) |
| 46 | }) |
| 47 | } |
| 48 | |
| 49 | func TestFilterOnlyCat(t *testing.T) { |
| 50 | // Get a spec from the test definition in this file: |
nothing calls this directly
no test coverage detected