Files
hyperguild/internal/registry/registry_test.go
T
mathias 8a27ead91c
CI / Lint / Test / Vet (push) Failing after 12s
CI / Mirror to GitHub (push) Skipped
chore(lint): adopt the canonical .golangci.yml from infra/ci-templates
Canonical lives at infra ci-templates/golangci.yml, distributed by the
infra#309 pattern: byte-identical copies, checksum drift gate in infra. Do
not edit this file here -- edit the canonical and run `task ci:sync`.

Verified locally before pushing, not pushed-and-hoped: golangci-lint v2.11.4
against a Go 1.26.1 toolchain (matching CI) reports 0 issues here.

Also applies gofumpt, which this config enables and the golangci-lint v2
default set does not check at all. That gap is why the drift was invisible:
earlier passes ran gofmt, which is weaker. Mechanical, deterministic,
build+vet verified.
2026-09-05 14:42:59 +02:00

53 lines
1.3 KiB
Go

package registry_test
import (
"context"
"encoding/json"
"testing"
"git.d-ma.be/mathias/hyperguild/internal/registry"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
type stubSkill struct {
name string
}
func (s stubSkill) Name() string { return s.name }
func (s stubSkill) Tools() []registry.ToolDef {
return []registry.ToolDef{{
Name: s.name + "_tool",
Description: "stub tool",
InputSchema: json.RawMessage(`{"type":"object","properties":{}}`),
}}
}
func (s stubSkill) Handle(ctx context.Context, tool string, args json.RawMessage) (json.RawMessage, error) {
return json.RawMessage(`{"ok":true}`), nil
}
func TestRegistryRoutes(t *testing.T) {
r := registry.New()
r.Register(stubSkill{name: "tdd"})
result, err := r.Dispatch(context.Background(), "tdd_tool", json.RawMessage(`{}`))
require.NoError(t, err)
assert.JSONEq(t, `{"ok":true}`, string(result))
}
func TestRegistryUnknownTool(t *testing.T) {
r := registry.New()
_, err := r.Dispatch(context.Background(), "unknown_tool", json.RawMessage(`{}`))
assert.ErrorContains(t, err, "unknown tool")
}
func TestRegistryListsTools(t *testing.T) {
r := registry.New()
r.Register(stubSkill{name: "tdd"})
tools := r.Tools()
require.Len(t, tools, 1)
assert.Equal(t, "tdd_tool", tools[0].Name)
}