You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			51 lines
		
	
	
		
			757 B
		
	
	
	
		
			Go
		
	
			
		
		
	
	
			51 lines
		
	
	
		
			757 B
		
	
	
	
		
			Go
		
	
| package obp_test
 | |
| 
 | |
| import (
 | |
| 	"bytes"
 | |
| 	"testing"
 | |
| 
 | |
| 	"code.ndumas.com/ndumas/obsidian-pipeline"
 | |
| )
 | |
| 
 | |
| func Test_BasicValidation(t *testing.T) {
 | |
| 	t.Parallel()
 | |
| 	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,
 | |
| 		},
 | |
| 	}
 | |
| 
 | |
| 	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()
 | |
| 			}
 | |
| 		})
 | |
| 	}
 | |
| }
 |