-
Notifications
You must be signed in to change notification settings - Fork 5
/
ref_index_test.go
34 lines (27 loc) · 1.03 KB
/
ref_index_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package vervet_test
import (
"testing"
qt "github.com/frankban/quicktest"
"github.com/snyk/vervet/v8"
"github.com/snyk/vervet/v8/testdata"
)
func TestRefIndexSource(t *testing.T) {
c := qt.New(t)
doc, err := vervet.NewDocumentFile(testdata.Path("resources/_examples/hello-world/2021-06-01/spec.yaml"))
c.Assert(err, qt.IsNil)
ix, err := vervet.NewRefIndex(doc.T)
c.Assert(err, qt.IsNil)
c.Assert(ix.HasRef("#/components/schemas/HelloWorld"), qt.IsTrue)
c.Assert(ix.HasRef("#/components/headers/DeprecationHeader"), qt.IsFalse)
c.Assert(ix.HasRef("#/components/schemas/Nope"), qt.IsFalse)
}
func TestRefIndexCompiled(t *testing.T) {
c := qt.New(t)
doc, err := vervet.NewDocumentFile(testdata.Path("output/2021-06-01~experimental/spec.json"))
c.Assert(err, qt.IsNil)
ix, err := vervet.NewRefIndex(doc.T)
c.Assert(err, qt.IsNil)
c.Assert(ix.HasRef("#/components/schemas/HelloWorld"), qt.IsTrue)
c.Assert(ix.HasRef("#/components/headers/DeprecationHeader"), qt.IsTrue)
c.Assert(ix.HasRef("#/components/schemas/Nope"), qt.IsFalse)
}