forked from mtusi2026/mtusi2026lab7
на оценку 4
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package student_tests
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"mtusi2026lab7/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
|
||||
}
|
||||
Reference in New Issue
Block a user