refactor: Remove Token management and integrate Redis for authentication
- Deleted the Token model and its repository, transitioning to a Redis-based token management system. - Updated the service layer to utilize Redis for token storage, enhancing performance and scalability. - Refactored the container to remove TokenRepository and integrate the new token service. - Cleaned up the Dockerfile and other files by removing unnecessary whitespace and comments. - Enhanced error handling and logging for Redis initialization and usage.
This commit is contained in:
38
internal/errors/errors_test.go
Normal file
38
internal/errors/errors_test.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package errors
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestAppErrorBasics(t *testing.T) {
|
||||
root := errors.New("root")
|
||||
appErr := NewBadRequest("bad", root)
|
||||
|
||||
if appErr.Code != 400 || appErr.Message != "bad" {
|
||||
t.Fatalf("unexpected appErr fields: %+v", appErr)
|
||||
}
|
||||
if got := appErr.Error(); got != "bad: root" {
|
||||
t.Fatalf("unexpected Error(): %s", got)
|
||||
}
|
||||
if !Is(appErr, root) {
|
||||
t.Fatalf("Is should match wrapped error")
|
||||
}
|
||||
var target *AppError
|
||||
if !As(appErr, &target) {
|
||||
t.Fatalf("As should succeed")
|
||||
}
|
||||
}
|
||||
|
||||
func TestWrap(t *testing.T) {
|
||||
if Wrap(nil, "msg") != nil {
|
||||
t.Fatalf("Wrap nil should return nil")
|
||||
}
|
||||
err := errors.New("base")
|
||||
wrapped := Wrap(err, "ctx")
|
||||
if wrapped.Error() != "ctx: base" {
|
||||
t.Fatalf("wrap message mismatch: %v", wrapped)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user