Phase 1 complete: coverage from 70.1% to 85.6% (130+ tests, all passing). New test files: - lifecycle_test.go: full claim -> process -> complete integration flows - allowance_edge_test.go: boundary conditions for token/job/concurrent limits - allowance_error_test.go: mock errorStore covering all RecordUsage error paths - embed_test.go: Prompt() hit/miss and content trimming - service_test.go: DefaultServiceOptions, TaskPrompt, TaskCommit type coverage - completion_git_test.go: real git repos for AutoCommit, CreateBranch, CommitAndSync - context_git_test.go: findRelatedCode with keyword search, file limits, truncation Updated config_test.go with YAML fallback, env override, and empty-dir paths. Co-Authored-By: Charon <developers@lethean.io>
79 lines
1.8 KiB
Go
79 lines
1.8 KiB
Go
package agentic
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestDefaultServiceOptions_Good(t *testing.T) {
|
|
opts := DefaultServiceOptions()
|
|
|
|
assert.Equal(t, []string{"Bash", "Read", "Glob", "Grep"}, opts.DefaultTools)
|
|
assert.False(t, opts.AllowEdit, "default should not allow edit")
|
|
}
|
|
|
|
func TestTaskPrompt_SetGetTaskID(t *testing.T) {
|
|
tp := &TaskPrompt{
|
|
Prompt: "test prompt",
|
|
WorkDir: "/tmp",
|
|
}
|
|
|
|
assert.Empty(t, tp.GetTaskID(), "should start empty")
|
|
|
|
tp.SetTaskID("task-abc-123")
|
|
assert.Equal(t, "task-abc-123", tp.GetTaskID())
|
|
|
|
tp.SetTaskID("task-def-456")
|
|
assert.Equal(t, "task-def-456", tp.GetTaskID(), "should allow overwriting")
|
|
}
|
|
|
|
func TestTaskPrompt_SetGetTaskID_Empty(t *testing.T) {
|
|
tp := &TaskPrompt{}
|
|
|
|
tp.SetTaskID("")
|
|
assert.Empty(t, tp.GetTaskID())
|
|
}
|
|
|
|
func TestTaskCommit_Fields(t *testing.T) {
|
|
tc := TaskCommit{
|
|
Path: "/home/user/project",
|
|
Name: "test-commit",
|
|
CanEdit: true,
|
|
}
|
|
|
|
assert.Equal(t, "/home/user/project", tc.Path)
|
|
assert.Equal(t, "test-commit", tc.Name)
|
|
assert.True(t, tc.CanEdit)
|
|
}
|
|
|
|
func TestTaskCommit_DefaultCanEdit(t *testing.T) {
|
|
tc := TaskCommit{
|
|
Path: "/tmp",
|
|
Name: "no-edit",
|
|
}
|
|
|
|
assert.False(t, tc.CanEdit, "default should be false")
|
|
}
|
|
|
|
func TestServiceOptions_CustomTools(t *testing.T) {
|
|
opts := ServiceOptions{
|
|
DefaultTools: []string{"Bash", "Read", "Write", "Edit"},
|
|
AllowEdit: true,
|
|
}
|
|
|
|
assert.Len(t, opts.DefaultTools, 4)
|
|
assert.True(t, opts.AllowEdit)
|
|
}
|
|
|
|
func TestTaskPrompt_AllFields(t *testing.T) {
|
|
tp := TaskPrompt{
|
|
Prompt: "Refactor the authentication module",
|
|
WorkDir: "/home/user/project",
|
|
AllowedTools: []string{"Bash", "Read", "Edit"},
|
|
}
|
|
|
|
assert.Equal(t, "Refactor the authentication module", tp.Prompt)
|
|
assert.Equal(t, "/home/user/project", tp.WorkDir)
|
|
assert.Equal(t, []string{"Bash", "Read", "Edit"}, tp.AllowedTools)
|
|
}
|