23 lines
617 B
Go
23 lines
617 B
Go
package storage
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"gardomatic.kleiax.de/internal/platform/validate"
|
|
)
|
|
|
|
func TestValidateJournalEntry(t *testing.T) {
|
|
valid := validate.New()
|
|
ValidateJournalEntry(valid, JournalEntry{Title: "Erste Ernte", Body: "**Drei** Tomaten geerntet."})
|
|
if !valid.Valid() {
|
|
t.Fatalf("valid entry rejected: %#v", valid.Errors)
|
|
}
|
|
|
|
invalid := validate.New()
|
|
ValidateJournalEntry(invalid, JournalEntry{Title: " ", Body: strings.Repeat("x", 100_001)})
|
|
if invalid.Errors["title"] == "" || invalid.Errors["body"] == "" {
|
|
t.Fatalf("expected title and body errors, got %#v", invalid.Errors)
|
|
}
|
|
}
|