lab7: безопасность, mTLS, OpenBao и PKI lifecycle
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