ms-tester/internal/models/result.go

29 lines
706 B
Go
Raw Normal View History

2024-08-17 12:23:35 +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 12:23:35 +00:00
type Result int32
const (
2024-08-20 22:54:46 +00:00
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
2024-08-17 12:23:35 +00:00
)
2024-08-22 23:02:14 +00:00
var ErrBadResult = errors.New("bad result")
2024-08-17 12:23:35 +00:00
func (result Result) Valid() error {
2024-08-20 22:54:46 +00:00
switch result {
case NotTested, Accepted, TimeLimitExceeded, MemoryLimitExceeded, CompilationError, SystemFailDuringTesting:
return nil
}
2024-08-22 23:02:14 +00:00
return lib.ServiceError(ErrBadResult, lib.ErrValidationFailed, "bad result")
2024-08-17 12:23:35 +00:00
}