ms-tester/internal/models/result.go
2024-08-23 04:02:14 +05:00

29 lines
706 B
Go

package models
import (
"errors"
"git.sch9.ru/new_gate/ms-tester/internal/lib"
)
type Result int32
const (
NotTested Result = 0 // change only with schema change
Accepted Result = 1
CompilationError Result = 2
MemoryLimitExceeded Result = 3
TimeLimitExceeded Result = 4
SystemFailDuringTesting Result = 5
Testing Result = 6
)
var ErrBadResult = errors.New("bad result")
func (result Result) Valid() error {
switch result {
case NotTested, Accepted, TimeLimitExceeded, MemoryLimitExceeded, CompilationError, SystemFailDuringTesting:
return nil
}
return lib.ServiceError(ErrBadResult, lib.ErrValidationFailed, "bad result")
}