ms-tester/pkg/models/testgroup.go

35 lines
725 B
Go
Raw Normal View History

2024-08-17 10:43:15 +00:00
package models
2024-08-22 23:02:14 +00:00
import (
"errors"
"git.sch9.ru/new_gate/ms-tester/internal/lib"
)
2024-08-17 10:43:15 +00:00
type TestingStrategy int32
const (
2024-08-20 22:54:46 +00:00
EachTestTS TestingStrategy = 1
CompleteGroupTS TestingStrategy = 2
2024-08-17 10:43:15 +00:00
)
type Testgroup struct {
2024-08-20 22:54:46 +00:00
Id *int32 `db:"id"`
ProblemId *int32 `db:"problem_id"`
TestingStrategy *TestingStrategy `db:"testing_strategy"`
2024-08-18 13:41:08 +00:00
}
2024-08-20 22:54:46 +00:00
type TestGroupData struct {
Ts TestingStrategy
TestAmount int32
2024-08-17 10:43:15 +00:00
}
2024-08-22 23:02:14 +00:00
var ErrBadTestingStrategy = errors.New("bad testing strategy")
2024-08-20 22:54:46 +00:00
func (ts TestingStrategy) Valid() error {
2024-08-17 10:43:15 +00:00
switch ts {
case EachTestTS, CompleteGroupTS:
return nil
}
2024-08-22 23:02:14 +00:00
return lib.ServiceError(ErrBadTestingStrategy, lib.ErrValidationFailed, "bad testing strategy")
2024-08-17 10:43:15 +00:00
}