sp4-debug-1770477266/workers/worker-svc/internal/handlers/chat_test.go
rdev-worker 5a877ca1a1
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
feat: implement mesh-interop service communication
Add auth-svc /validate endpoint for token checking
Add chat-svc with auth client and Redis task queue
Add worker-svc chat handler for task processing

Co-Authored-By: Claude Code <claude@anthropic.com>
2026-02-07 16:45:22 +00:00

77 lines
1.5 KiB
Go

package handlers
import (
"context"
"testing"
"git.threesix.ai/jordan/sp4-debug-1770477266/pkg/logging"
"git.threesix.ai/jordan/sp4-debug-1770477266/pkg/queue"
)
func TestNewChatProcessHandler_Success(t *testing.T) {
handler := NewChatProcessHandler(logging.Nop())
job := &queue.Job{
ID: "job-123",
Type: JobTypeChatProcess,
Payload: map[string]any{
"user_id": "user-456",
"message": "Hello, world!",
},
}
err := handler(context.Background(), job)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
}
func TestNewChatProcessHandler_MissingUserID(t *testing.T) {
handler := NewChatProcessHandler(logging.Nop())
job := &queue.Job{
ID: "job-123",
Type: JobTypeChatProcess,
Payload: map[string]any{
"message": "Hello",
},
}
err := handler(context.Background(), job)
if err == nil {
t.Fatal("expected error for missing user_id")
}
}
func TestNewChatProcessHandler_MissingMessage(t *testing.T) {
handler := NewChatProcessHandler(logging.Nop())
job := &queue.Job{
ID: "job-123",
Type: JobTypeChatProcess,
Payload: map[string]any{
"user_id": "user-456",
},
}
err := handler(context.Background(), job)
if err == nil {
t.Fatal("expected error for missing message")
}
}
func TestNewChatProcessHandler_EmptyPayload(t *testing.T) {
handler := NewChatProcessHandler(logging.Nop())
job := &queue.Job{
ID: "job-123",
Type: JobTypeChatProcess,
Payload: map[string]any{},
}
err := handler(context.Background(), job)
if err == nil {
t.Fatal("expected error for empty payload")
}
}