23 lines
566 B
Go
23 lines
566 B
Go
package model
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/go-playground/validator/v10"
|
|
)
|
|
|
|
func TestMaterialRequestsRequireCategoryID(t *testing.T) {
|
|
validate := validator.New()
|
|
validate.SetTagName("binding")
|
|
|
|
create := CreateMaterialRequest{MaterialCode: "MAT-001", Name: "轴承"}
|
|
if err := validate.Struct(create); err == nil {
|
|
t.Fatal("create request without category_id should be rejected")
|
|
}
|
|
|
|
update := UpdateMaterialRequest{Name: "轴承"}
|
|
if err := validate.Struct(update); err == nil {
|
|
t.Fatal("update request without category_id should be rejected")
|
|
}
|
|
}
|