Unit tests and linting cleanup
parent
13e1abd65a
commit
5c48fe6b22
@ -1,18 +1,50 @@
|
||||
package obp_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"testing"
|
||||
|
||||
"code.ndumas.com/ndumas/obsidian-pipeline"
|
||||
)
|
||||
|
||||
func Test_BasicValidation(t *testing.T) {
|
||||
t.Parallel()
|
||||
t.Run("KeyMissing", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
t.Fail()
|
||||
})
|
||||
tt := []struct {
|
||||
name string
|
||||
b *bytes.Buffer
|
||||
expected error
|
||||
}{
|
||||
{
|
||||
name: "KeyMissing",
|
||||
b: bytes.NewBufferString(`
|
||||
---
|
||||
boop: "bop"
|
||||
---
|
||||
# Markdown Content
|
||||
`),
|
||||
expected: nil,
|
||||
},
|
||||
{
|
||||
name: "KeyTypeMismatch",
|
||||
b: bytes.NewBufferString(`
|
||||
---
|
||||
title: 2
|
||||
---
|
||||
# Markdown Content
|
||||
`),
|
||||
expected: nil,
|
||||
},
|
||||
}
|
||||
|
||||
t.Run("KeyTypeMismatch", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
t.Fail()
|
||||
})
|
||||
for _, tc := range tt {
|
||||
tc := tc
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
err := obp.Validate("https://schemas.ndumas.com/obsidian/note.schema.json", tc.b)
|
||||
if err == nil {
|
||||
t.Log("Expected Validate() to fail on input")
|
||||
t.Fail()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue