refactor: разнести пакеты и обновить валидацию
This commit is contained in:
31
protocol/validation_test.go
Normal file
31
protocol/validation_test.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package protocol
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestValidateAcceptsValidState(t *testing.T) {
|
||||
err := Validate(DefaultConfig(), ContentState{
|
||||
Route: "3",
|
||||
Text: "Гостиный двор - Gostiny dvor",
|
||||
Template: "Гостиный двор",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Validate returned error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateWrapsInvalidData(t *testing.T) {
|
||||
err := Validate(DefaultConfig(), ContentState{
|
||||
Route: "1234",
|
||||
Text: "ok",
|
||||
Template: "tpl",
|
||||
})
|
||||
if err == nil {
|
||||
t.Fatal("expected error")
|
||||
}
|
||||
if !errors.Is(err, ErrInvalidData) {
|
||||
t.Fatalf("expected ErrInvalidData, got %v", err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user