Skip to content

Commit

Permalink
Add TestFailParseSchema
Browse files Browse the repository at this point in the history
  • Loading branch information
tigrannajaryan committed Oct 4, 2021
1 parent da794ff commit ce49916
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions schema/v1.0/parser_test.go
Expand Up @@ -15,26 +15,37 @@
package schema

import (
"bytes"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestParseSchema(t *testing.T) {
func TestParseSchemaFile(t *testing.T) {
ts, err := ParseFile("testdata/valid-example.yaml")
require.NoError(t, err)
require.NotNil(t, ts)
assert.NoError(t, err)
assert.NotNil(t, ts)
}

func TestFailParseSchema(t *testing.T) {
func TestFailParseSchemaFile(t *testing.T) {
ts, err := ParseFile("testdata/unsupported-file-format.yaml")
require.Error(t, err)
require.Nil(t, ts)
assert.Error(t, err)
assert.Nil(t, ts)

ts, err = ParseFile("testdata/invalid-schema-url.yaml")
require.Error(t, err)
require.Nil(t, ts)
assert.Error(t, err)
assert.Nil(t, ts)
}

func TestFailParseSchema(t *testing.T) {
_, err := Parse(bytes.NewReader([]byte("")))
assert.Error(t, err)

_, err = Parse(bytes.NewReader([]byte("invalid yaml")))
assert.Error(t, err)

_, err = Parse(bytes.NewReader([]byte("file_format: 1.0.0")))
assert.Error(t, err)
}

func TestCheckFileFormatField(t *testing.T) {
Expand Down

0 comments on commit ce49916

Please sign in to comment.