34 lines
636 B
Go
34 lines
636 B
Go
|
// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
|
||
|
|
||
|
package resource
|
||
|
|
||
|
import (
|
||
|
_ "fmt"
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
_ "log"
|
||
|
"strings"
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func TestNewYAMLEncoder(t *testing.T) {
|
||
|
var yamlDoc strings.Builder
|
||
|
e := NewYAMLEncoder(&yamlDoc)
|
||
|
assert.NotNil(t, e)
|
||
|
}
|
||
|
|
||
|
func TestNewEncoderEncodeJSON(t *testing.T) {
|
||
|
var jsonDoc strings.Builder
|
||
|
file := NewFile()
|
||
|
file.Path = "foo"
|
||
|
|
||
|
e := NewJSONEncoder(&jsonDoc)
|
||
|
assert.NotNil(t, e)
|
||
|
docErr := e.Encode(file)
|
||
|
assert.Nil(t, docErr)
|
||
|
|
||
|
s := NewSchema(file.Type())
|
||
|
|
||
|
validateErr := s.Validate(jsonDoc.String())
|
||
|
assert.Nil(t, validateErr)
|
||
|
}
|