rdev/internal/service/sdlc_generate_test.go
jordan d69da6d627 feat: add structured logging infrastructure and SDLC extensions
Major changes:
- Add internal/logging package with field constants, context propagation,
  sensitive data auto-redaction, and per-component log levels
- Add worker timeout constants (TimeoutQuickOp, TimeoutHealthCheck, etc.)
- Extend SDLC with callback handlers, generate endpoints, and executor
- Add new cookbook trees for aeries and slackpath progression
- Add skeleton templates for queue, realtime, and microservices
- Add worker component template with async job processing
- Refactor services and handlers to use new logging infrastructure
- Split component.go into component_infra.go and component_listing.go

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 22:56:04 -07:00

107 lines
2.3 KiB
Go

package service
import (
"testing"
"github.com/orchard9/rdev/internal/domain"
)
func TestSDLCGenerateService_BuildPrompt(t *testing.T) {
tests := []struct {
name string
feature string
artifactType string
taskID string
wantPrompt string
}{
{
name: "spec artifact",
feature: "user-auth",
artifactType: "spec",
taskID: "",
wantPrompt: "/spec-feature user-auth",
},
{
name: "design artifact",
feature: "user-auth",
artifactType: "design",
taskID: "",
wantPrompt: "/design-feature user-auth",
},
{
name: "tasks artifact",
feature: "user-auth",
artifactType: "tasks",
taskID: "",
wantPrompt: "/breakdown-feature user-auth",
},
{
name: "code with task_id",
feature: "user-auth",
artifactType: "code",
taskID: "task-001",
wantPrompt: "/implement-task user-auth task-001",
},
{
name: "code without task_id",
feature: "user-auth",
artifactType: "code",
taskID: "",
wantPrompt: "/implement-feature user-auth",
},
{
name: "qa artifact",
feature: "user-auth",
artifactType: "qa",
taskID: "",
wantPrompt: "/run-qa user-auth",
},
{
name: "unknown artifact type falls back",
feature: "user-auth",
artifactType: "unknown",
taskID: "",
wantPrompt: "Generate unknown artifact for feature user-auth",
},
}
svc := &SDLCGenerateService{}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := svc.buildPrompt(tt.feature, tt.artifactType, tt.taskID)
if got != tt.wantPrompt {
t.Errorf("buildPrompt(%q, %q, %q) = %q, want %q",
tt.feature, tt.artifactType, tt.taskID, got, tt.wantPrompt)
}
})
}
}
func TestIsValidGenerateArtifactType(t *testing.T) {
tests := []struct {
artifactType string
want bool
}{
{"spec", true},
{"design", true},
{"tasks", true},
{"code", true},
{"qa", true},
{"invalid", false},
{"", false},
{"review", false},
{"audit", false},
}
for _, tt := range tests {
t.Run(tt.artifactType, func(t *testing.T) {
got := domain.IsValidGenerateArtifactType(tt.artifactType)
if got != tt.want {
t.Errorf("IsValidGenerateArtifactType(%q) = %v, want %v",
tt.artifactType, got, tt.want)
}
})
}
}