Implement lab 2 with PostgreSQL, Valkey admission and Helm deployment

This commit is contained in:
Vladislav Agapov
2026-10-15 17:09:26 +03:00
parent 65003b6119
commit b90581f613
184 changed files with 15853 additions and 56 deletions
@@ -0,0 +1,34 @@
package fiber
import (
"errors"
"fmt"
"testing"
"go.lab260.ru/fielderr"
"gitea.privcloud.tech/vlad_marlo/mtusi2026lab2/internal/service"
)
// TestPublicErrorSafety maps wrapped application failures without exposing internal details.
func TestPublicErrorSafety(t *testing.T) {
t.Run("wrapped application error", func(t *testing.T) {
err := publicError(fmt.Errorf("private database detail: %w", service.ErrConflict))
response := errorResponse(err, "request")
if response.Error.Code != codeConflict || response.Error.Message != "username already exists" {
t.Fatalf("unexpected response: %+v", response)
}
})
t.Run("unknown error", func(t *testing.T) {
err := publicError(errors.New("private database detail"))
if err != errInternal {
t.Fatalf("unexpected public error: %v", err)
}
})
t.Run("foreign public status", func(t *testing.T) {
err := fielderr.WithStatus(errors.New("private detail"), fielderr.NewStatusCode(codeInvalid), "private detail")
if publicError(err) != errInternal {
t.Fatal("untrusted error metadata reached the public response")
}
})
}