forked from MiniCodeMonkey/chief
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathembed_test.go
More file actions
117 lines (96 loc) · 3.24 KB
/
embed_test.go
File metadata and controls
117 lines (96 loc) · 3.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
package embed
import (
"strings"
"testing"
)
func TestGetPrompt(t *testing.T) {
prdPath := "/path/to/prd.json"
progressPath := "/path/to/progress.md"
prompt := GetPrompt(prdPath, progressPath)
// Verify the PRD path placeholder was substituted
if strings.Contains(prompt, "{{PRD_PATH}}") {
t.Error("Expected {{PRD_PATH}} to be substituted")
}
// Verify the progress path placeholder was substituted
if strings.Contains(prompt, "{{PROGRESS_PATH}}") {
t.Error("Expected {{PROGRESS_PATH}} to be substituted")
}
// Verify the PRD path appears in the prompt
if !strings.Contains(prompt, prdPath) {
t.Errorf("Expected prompt to contain PRD path %q", prdPath)
}
// Verify the progress path appears in the prompt
if !strings.Contains(prompt, progressPath) {
t.Errorf("Expected prompt to contain progress path %q", progressPath)
}
// Verify the prompt contains key instructions
if !strings.Contains(prompt, "chief-complete") {
t.Error("Expected prompt to contain chief-complete instruction")
}
if !strings.Contains(prompt, "ralph-status") {
t.Error("Expected prompt to contain ralph-status instruction")
}
if !strings.Contains(prompt, "passes: true") {
t.Error("Expected prompt to contain passes: true instruction")
}
}
func TestPromptTemplateNotEmpty(t *testing.T) {
if promptTemplate == "" {
t.Error("Expected promptTemplate to be embedded and non-empty")
}
}
func TestGetConvertPrompt(t *testing.T) {
prdContent := "# My Feature\n\nA cool feature PRD."
prompt := GetConvertPrompt(prdContent)
// Verify the prompt is not empty
if prompt == "" {
t.Error("Expected GetConvertPrompt() to return non-empty prompt")
}
// Verify PRD content is inlined
if !strings.Contains(prompt, prdContent) {
t.Error("Expected prompt to contain the inlined PRD content")
}
if strings.Contains(prompt, "{{PRD_CONTENT}}") {
t.Error("Expected {{PRD_CONTENT}} to be substituted")
}
// Verify key instructions are present
if !strings.Contains(prompt, "JSON") {
t.Error("Expected prompt to mention JSON")
}
if !strings.Contains(prompt, "userStories") {
t.Error("Expected prompt to describe userStories structure")
}
if !strings.Contains(prompt, `"passes": false`) {
t.Error("Expected prompt to specify passes: false default")
}
}
func TestGetInitPrompt(t *testing.T) {
prdDir := "/path/to/.chief/prds/main"
// Test with no context
prompt := GetInitPrompt(prdDir, "")
if !strings.Contains(prompt, "No additional context provided") {
t.Error("Expected default context message")
}
// Verify PRD directory is substituted
if !strings.Contains(prompt, prdDir) {
t.Errorf("Expected prompt to contain PRD directory %q", prdDir)
}
if strings.Contains(prompt, "{{PRD_DIR}}") {
t.Error("Expected {{PRD_DIR}} to be substituted")
}
// Test with context
context := "Build a todo app"
promptWithContext := GetInitPrompt(prdDir, context)
if !strings.Contains(promptWithContext, context) {
t.Error("Expected context to be substituted in prompt")
}
}
func TestGetEditPrompt(t *testing.T) {
prompt := GetEditPrompt("/test/path/prds/main")
if prompt == "" {
t.Error("Expected GetEditPrompt() to return non-empty prompt")
}
if !strings.Contains(prompt, "/test/path/prds/main") {
t.Error("Expected prompt to contain the PRD directory path")
}
}