agent/pkg/agentic/render_plan_test.go
Snider f83c753277 feat(v0.8.0): full AX migration — ServiceRuntime, Actions, quality gates, transport
go-process:
- Register factory, Result lifecycle, 5 named Action handlers
- Start/Run/StartWithOptions/RunWithOptions all return core.Result
- core.ID() replaces fmt.Sprintf, core.As replaces errors.As

core/agent:
- PrepSubsystem + monitor.Subsystem + setup.Service embed ServiceRuntime[T]
- 22 named Actions + agent.completion Task pipeline in OnStartup
- ChannelNotifier removed — all IPC via c.ACTION(messages.X{})
- proc.go: all methods via s.Core().Process(), returns core.Result
- status.go: WriteAtomic + JSONMarshalString
- paths.go: Fs.NewUnrestricted() replaces unsafe.Pointer
- transport.go: ONE net/http file — HTTPGet/HTTPPost/HTTPDo/MCP transport
- All disallowed imports eliminated from source files (13 quality gates)
- String concat eliminated — core.Concat() throughout
- 1:1 _test.go + _example_test.go for every source file
- Reference docs synced from core/go v0.8.0
- RFC-025 updated with net/http, net/url, io/fs quality gates
- lib.go: io/fs eliminated via Data.ListNames, Array[T].Deduplicate

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-26 01:27:46 +00:00

82 lines
2.3 KiB
Go

// SPDX-License-Identifier: EUPL-1.2
package agentic
import (
"testing"
"time"
core "dappco.re/go/core"
"github.com/stretchr/testify/assert"
)
// --- renderPlan ---
func TestPrep_RenderPlan_Good_BugFix(t *testing.T) {
s := &PrepSubsystem{
ServiceRuntime: core.NewServiceRuntime(testCore, AgentOptions{}),
backoff: make(map[string]time.Time),
failCount: make(map[string]int),
}
result := s.renderPlan("bug-fix", nil, "Fix the auth bug")
if result == "" {
t.Skip("bug-fix template not available in embedded assets")
}
assert.Contains(t, result, "Bug Fix")
assert.Contains(t, result, "Fix the auth bug")
assert.Contains(t, result, "Phase 1")
assert.Contains(t, result, "Investigation")
}
func TestPrep_RenderPlan_Good_WithVariables(t *testing.T) {
s := &PrepSubsystem{
ServiceRuntime: core.NewServiceRuntime(testCore, AgentOptions{}),
backoff: make(map[string]time.Time),
failCount: make(map[string]int),
}
vars := map[string]string{
"bug_description": "Login fails on mobile",
"location": "pkg/auth/handler.go",
}
result := s.renderPlan("bug-fix", vars, "Fix login")
if result == "" {
t.Skip("bug-fix template not available")
}
assert.Contains(t, result, "Fix login")
}
func TestPrep_RenderPlan_Bad_UnknownTemplate(t *testing.T) {
s := &PrepSubsystem{
ServiceRuntime: core.NewServiceRuntime(testCore, AgentOptions{}),
backoff: make(map[string]time.Time),
failCount: make(map[string]int),
}
result := s.renderPlan("nonexistent-template-slug", nil, "task")
assert.Empty(t, result)
}
func TestPrep_RenderPlan_Good_NoTask(t *testing.T) {
s := &PrepSubsystem{
ServiceRuntime: core.NewServiceRuntime(testCore, AgentOptions{}),
backoff: make(map[string]time.Time),
failCount: make(map[string]int),
}
result := s.renderPlan("bug-fix", nil, "")
if result == "" {
t.Skip("template not available")
}
assert.NotContains(t, result, "**Task:**")
}
func TestPrep_RenderPlan_Good_NewFeature(t *testing.T) {
s := &PrepSubsystem{
ServiceRuntime: core.NewServiceRuntime(testCore, AgentOptions{}),
backoff: make(map[string]time.Time),
failCount: make(map[string]int),
}
result := s.renderPlan("new-feature", nil, "Add caching")
if result == "" {
t.Skip("new-feature template not available")
}
assert.Contains(t, result, "Add caching")
}