forked from mtusi2026/mtusi2026lab4
37 lines
761 B
Go
37 lines
761 B
Go
package student_tests
|
|
|
|
import (
|
|
"time"
|
|
|
|
"mtusi2026lab4/internal/application"
|
|
)
|
|
|
|
const testCursorSigningKey = "student-tests-cursor-signing-key-at-least-32-bytes"
|
|
|
|
func newTestService(
|
|
repository application.Repository,
|
|
sessionTTL time.Duration,
|
|
options ...application.ServiceOption,
|
|
) *application.Service {
|
|
if sessionTTL <= 0 {
|
|
sessionTTL = time.Hour
|
|
}
|
|
codec, err := application.NewCursorCodec(testCursorSigningKey)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
service, err := application.NewService(repository, codec, sessionTTL, options...)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return service
|
|
}
|
|
|
|
func newTestCursorCodec() *application.CursorCodec {
|
|
codec, err := application.NewCursorCodec(testCursorSigningKey)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return codec
|
|
}
|