forked from mtusi2026/mtusi2026lab7
База lab7: контракт 1.7.0 и реализация lab1–lab6
Перенесены cmd/internal/config, compose.yaml, Dockerfile, скрипты, student-tests и evidence из mtusi-messenger (master, lab6). Skeleton lab7 (openapi/infrastructure 1.7.0, trust-matrix.md, security/THREAT_MODEL.md, infra/openbao, tests/security.py) сохранён; make test-security добавлен в Makefile.
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package worker
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"mtusi-messenger/internal/domain"
|
||||
)
|
||||
|
||||
func TestClassifyFailure(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
err error
|
||||
wantCode string
|
||||
permanent bool
|
||||
}{
|
||||
{name: "typed permanent", err: permanentError{code: "invalid_image", err: errors.New("bad")}, wantCode: "invalid_image", permanent: true},
|
||||
{name: "validation", err: domain.ErrValidation, wantCode: "invalid_image", permanent: true},
|
||||
{name: "deadline", err: context.DeadlineExceeded, wantCode: "processing_timeout", permanent: false},
|
||||
{name: "transient", err: errors.New("temporary"), wantCode: "processing_failed", permanent: false},
|
||||
}
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
code, permanent := classifyFailure(test.err)
|
||||
if code != test.wantCode || permanent != test.permanent {
|
||||
t.Fatalf("classifyFailure() = (%q, %v), want (%q, %v)", code, permanent, test.wantCode, test.permanent)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user