MCPcopy Index your code
hub / github.com/oapi-codegen/oapi-codegen / TestFindReferences

Function TestFindReferences

pkg/codegen/prune_test.go:10–47  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func 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
49func TestFilterOnlyCat(t *testing.T) {
50 // Get a spec from the test definition in this file:

Callers

nothing calls this directly

Calls 4

findComponentRefsFunction · 0.85
filterOperationsByTagFunction · 0.85
RunMethod · 0.80
LenMethod · 0.45

Tested by

no test coverage detected