Skip to content

Commit

Permalink
updated test coverage
Browse files Browse the repository at this point in the history
Signed-off-by: Dave Shanley <[email protected]>
  • Loading branch information
daveshanley committed Jul 22, 2023
1 parent 40e3a24 commit cb5bafe
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
11 changes: 11 additions & 0 deletions datamodel/spec_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,17 @@ why:
assert.Len(t, *r.SpecBytes, 55)
}

func TestExtractSpecInfo_AnyDocument_JSON(t *testing.T) {

random := `{ "something" : "yeah"}`

r, e := ExtractSpecInfoWithDocumentCheck([]byte(random), true)
assert.Nil(t, e)
assert.NotNil(t, r.RootNode)
assert.Equal(t, "something", r.RootNode.Content[0].Content[0].Value)
assert.Len(t, *r.SpecBytes, 23)
}

func TestExtractSpecInfo_AnyDocumentFromConfig(t *testing.T) {

random := `something: yeah
Expand Down
19 changes: 15 additions & 4 deletions document_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,13 +291,24 @@ func TestDocument_RenderAndReload_Swagger(t *testing.T) {

func TestDocument_BuildModelPreBuild(t *testing.T) {
petstore, _ := ioutil.ReadFile("test_specs/petstorev3.json")
doc, _ := NewDocument(petstore)
doc.BuildV3Model()
doc.BuildV3Model()
_, _, _, e := doc.RenderAndReload()
_, e := NewDocument(petstore)
assert.Len(t, e, 0)
}

func TestDocument_AnyDoc(t *testing.T) {
anything := []byte(`{"chickens": "3.0.0", "burgers": {"title": "hello"}}`)
_, e := NewDocumentWithTypeCheck(anything, true)
assert.NoError(t, e)
}

func TestDocument_AnyDocWithConfig(t *testing.T) {
anything := []byte(`{"chickens": "3.0.0", "burgers": {"title": "hello"}}`)
_, e := NewDocumentWithConfiguration(anything, &datamodel.DocumentConfiguration{
BypassDocumentCheck: true,
})
assert.NoError(t, e)
}

func TestDocument_BuildModelCircular(t *testing.T) {
petstore, _ := ioutil.ReadFile("test_specs/circular-tests.yaml")
doc, _ := NewDocument(petstore)
Expand Down

0 comments on commit cb5bafe

Please sign in to comment.