76 lines
2.2 KiB
Go
76 lines
2.2 KiB
Go
package cc
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"superwork-tui/internal/config"
|
|
)
|
|
|
|
func TestBrainstormPrompt_SubstitutesVars(t *testing.T) {
|
|
s := config.DefaultSettings()
|
|
out := BrainstormPrompt(s, struct{ UserRequest, Nonce string }{"add dark mode", "deadbeef"})
|
|
if !strings.Contains(out, "add dark mode") {
|
|
t.Error("output should contain userRequest")
|
|
}
|
|
if !strings.Contains(out, "deadbeef") {
|
|
t.Error("output should contain nonce")
|
|
}
|
|
if strings.Contains(out, "{userRequest}") {
|
|
t.Error("placeholder {userRequest} should be replaced")
|
|
}
|
|
if strings.Contains(out, "{nonce}") {
|
|
t.Error("placeholder {nonce} should be replaced")
|
|
}
|
|
}
|
|
|
|
func TestBrainstormPrompt_SettingsOverride(t *testing.T) {
|
|
s := config.DefaultSettings()
|
|
s.BrainstormPrompt = "custom {userRequest}"
|
|
out := BrainstormPrompt(s, struct{ UserRequest, Nonce string }{"fix login", "xx"})
|
|
if out != "custom fix login" {
|
|
t.Errorf("expected 'custom fix login', got %q", out)
|
|
}
|
|
}
|
|
|
|
func TestBrainstormPrompt_DefaultFallback(t *testing.T) {
|
|
s := config.DefaultSettings()
|
|
out := BrainstormPrompt(s, struct{ UserRequest, Nonce string }{"req", "n"})
|
|
if out == "" {
|
|
t.Error("expected non-empty output from embedded default")
|
|
}
|
|
}
|
|
|
|
func TestBrainstormContinuePrompt_SubstitutesVars(t *testing.T) {
|
|
s := config.DefaultSettings()
|
|
out := BrainstormContinuePrompt(s, struct{ IssueNumber string }{"42"})
|
|
if !strings.Contains(out, "42") {
|
|
t.Error("output should contain issue number")
|
|
}
|
|
if strings.Contains(out, "{issueNumber}") {
|
|
t.Error("placeholder {issueNumber} should be replaced")
|
|
}
|
|
}
|
|
|
|
func TestImplementPlanPrompt_SubstitutesVars(t *testing.T) {
|
|
s := config.DefaultSettings()
|
|
out := ImplementPlanPrompt(s, struct{ PlanFile, IssueNumber string }{"docs/plan.md", "7"})
|
|
if !strings.Contains(out, "docs/plan.md") {
|
|
t.Error("output should contain planFile")
|
|
}
|
|
if !strings.Contains(out, "7") {
|
|
t.Error("output should contain issueNumber")
|
|
}
|
|
}
|
|
|
|
func TestReviewPrompt_SubstitutesVars(t *testing.T) {
|
|
s := config.DefaultSettings()
|
|
out := ReviewPrompt(s, struct{ PrNumber string }{"13"})
|
|
if !strings.Contains(out, "13") {
|
|
t.Error("output should contain prNumber")
|
|
}
|
|
if strings.Contains(out, "{prNumber}") {
|
|
t.Error("placeholder {prNumber} should be replaced")
|
|
}
|
|
}
|