package services import ( "testing" "github.com/breakpilot/school-service/internal/models" ) func TestCreateTimetableSolutionRequest_NoBindingTags(t *testing.T) { // CreateSolution accepts an empty name; the binding tag is intentionally // absent. Both states (with + without name) must pass validation. tests := []struct { name string req models.CreateTimetableSolutionRequest wantErr bool }{ {"empty", models.CreateTimetableSolutionRequest{}, false}, {"with name", models.CreateTimetableSolutionRequest{Name: "Schuljahr 26/27 Test"}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { if (validate.Struct(tt.req) != nil) != tt.wantErr { t.Errorf("unexpected validation outcome") } }) } } func TestCreateTimetableSolutionRequest_ParentAndLimit_Validation(t *testing.T) { uid := "00000000-0000-0000-0000-000000000001" secs := func(n int) *int { return &n } parent := func(s string) *string { return &s } tests := []struct { name string req models.CreateTimetableSolutionRequest wantErr bool }{ {"valid parent + limit", models.CreateTimetableSolutionRequest{ParentSolutionID: parent(uid), SecondsLimit: secs(60)}, false}, {"bad parent uuid", models.CreateTimetableSolutionRequest{ParentSolutionID: parent("not-a-uuid")}, true}, {"limit too low", models.CreateTimetableSolutionRequest{SecondsLimit: secs(1)}, true}, {"limit too high", models.CreateTimetableSolutionRequest{SecondsLimit: secs(9999)}, true}, {"limit at boundary (5)", models.CreateTimetableSolutionRequest{SecondsLimit: secs(5)}, false}, {"limit at boundary (600)", models.CreateTimetableSolutionRequest{SecondsLimit: secs(600)}, false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { if (validate.Struct(tt.req) != nil) != tt.wantErr { t.Errorf("unexpected validation outcome for %s", tt.name) } }) } }