2026-03-29 21:44:22 +00:00
|
|
|
// SPDX-License-Identifier: EUPL-1.2
|
|
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
"dappco.re/go/agent/pkg/agentic"
|
|
|
|
|
"dappco.re/go/agent/pkg/brain"
|
|
|
|
|
"dappco.re/go/agent/pkg/monitor"
|
|
|
|
|
"dappco.re/go/core"
|
|
|
|
|
"forge.lthn.ai/core/mcp/pkg/mcp"
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestMCP_RegisterMCPService_Good(t *testing.T) {
|
2026-03-30 21:30:49 +00:00
|
|
|
result := registerMCPService(core.New(core.WithOption("name", "core-agent")))
|
2026-03-29 21:44:22 +00:00
|
|
|
|
|
|
|
|
require.True(t, result.OK)
|
|
|
|
|
_, ok := result.Value.(*mcp.Service)
|
|
|
|
|
assert.True(t, ok)
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-30 00:00:33 +00:00
|
|
|
func TestMCP_RegisterMCPService_Bad(t *testing.T) {
|
|
|
|
|
result := registerMCPService(nil)
|
|
|
|
|
|
|
|
|
|
require.False(t, result.OK)
|
|
|
|
|
assert.EqualError(t, result.Value.(error), "main.registerMCPService: core is required")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestMCP_RegisterMCPService_Ugly(t *testing.T) {
|
2026-03-29 21:44:22 +00:00
|
|
|
c := core.New(
|
2026-03-30 21:30:49 +00:00
|
|
|
core.WithOption("name", "core-agent"),
|
2026-03-29 21:44:22 +00:00
|
|
|
core.WithService(agentic.ProcessRegister),
|
|
|
|
|
core.WithService(agentic.Register),
|
|
|
|
|
core.WithService(monitor.Register),
|
|
|
|
|
core.WithService(brain.Register),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
result := registerMCPService(c)
|
|
|
|
|
|
|
|
|
|
require.True(t, result.OK)
|
|
|
|
|
service := result.Value.(*mcp.Service)
|
|
|
|
|
assert.Len(t, service.Subsystems(), 3)
|
|
|
|
|
}
|