feat: add BVK exchange library
This commit is contained in:
38
validation_test.go
Normal file
38
validation_test.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package mila
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestValidateAcceptsValidUTF8State(t *testing.T) {
|
||||
err := Validate(DefaultConfig(), ContentState{
|
||||
Route: "3",
|
||||
Text: "Гостиный двор - Gostiny dvor",
|
||||
Template: "Гостиный двор",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Validate returned error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateRejectsTooLongRoute(t *testing.T) {
|
||||
err := Validate(DefaultConfig(), ContentState{
|
||||
Route: "1234",
|
||||
Text: "ok",
|
||||
Template: "tpl",
|
||||
})
|
||||
if err == nil {
|
||||
t.Fatal("expected validation error")
|
||||
}
|
||||
if !IsValidationError(err) {
|
||||
t.Fatalf("expected ValidationError, got %T", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateRejectsMissingTemplate(t *testing.T) {
|
||||
err := Validate(DefaultConfig(), ContentState{
|
||||
Route: "3",
|
||||
Text: "ok",
|
||||
})
|
||||
if err == nil {
|
||||
t.Fatal("expected validation error")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user