[feature] migrate to monorepo
This commit is contained in:
commit
05ddc1f783
267 changed files with 75165 additions and 0 deletions
6
backend/internal/auth/auth.go
Normal file
6
backend/internal/auth/auth.go
Normal file
|
@ -0,0 +1,6 @@
|
|||
package auth
|
||||
|
||||
// Constants for auth-related context keys
|
||||
const (
|
||||
UserIDKey = "user_id"
|
||||
)
|
27
backend/internal/auth/auth_test.go
Normal file
27
backend/internal/auth/auth_test.go
Normal file
|
@ -0,0 +1,27 @@
|
|||
package auth
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestUserIDKey(t *testing.T) {
|
||||
// Test that the UserIDKey constant is defined correctly
|
||||
if UserIDKey != "user_id" {
|
||||
t.Errorf("UserIDKey = %v, want %v", UserIDKey, "user_id")
|
||||
}
|
||||
|
||||
// Test context with user ID
|
||||
ctx := context.WithValue(context.Background(), UserIDKey, "test-user-123")
|
||||
value := ctx.Value(UserIDKey)
|
||||
if value != "test-user-123" {
|
||||
t.Errorf("Context value = %v, want %v", value, "test-user-123")
|
||||
}
|
||||
|
||||
// Test context without user ID
|
||||
emptyCtx := context.Background()
|
||||
emptyValue := emptyCtx.Value(UserIDKey)
|
||||
if emptyValue != nil {
|
||||
t.Errorf("Empty context value = %v, want nil", emptyValue)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue