Files
archie/internal/config/profile_test.go
T
sam 608403c1f9 feat(kit)!: a Kit profile names one Kit image, a workload or a published set
kitrun ran the first Kit of a profile's list as the container image, so
every mixin's layers (its tools, skills and staged context) were dropped
without a refusal. A profile's `kit` is now one digest-pinned reference:
a workload Kit, or a published Kit set, which the Kit spec's frontend
merges from a workload and its mixins into one image. archie composes no
Kits itself, and a bare mixin is refused with a pointer to publishing a
set. kit.Compose had no production caller left and is removed.

BREAKING CHANGE: `[containers.profiles.X] kit` and the agent-profiles
document's `kit` are a string, not a list. A stored list fails to decode
and must be rewritten as the one workload or set reference.

Part of archie-core-egkf.6.
2026-09-28 02:04:04 +10:00

66 lines
2.4 KiB
Go

package config
import (
"slices"
"strings"
"testing"
)
func TestContainerProfileResolution(t *testing.T) {
c := ContainerConfig{Image: "archie-agent:1", Profiles: map[string]AgentProfile{
"net": {Image: "archie-agent-net:1", Tools: []string{"whois"}},
"quiet": {Tools: []string{"notes"}},
}}
tests := []struct {
name, profile, wantImage, wantErr string
wantTools []string
}{
{name: "default profile", profile: "", wantImage: "archie-agent:1"},
{name: "named profile", profile: "net", wantImage: "archie-agent-net:1", wantTools: []string{"whois"}},
{name: "profile without an image uses the default image", profile: "quiet", wantImage: "archie-agent:1", wantTools: []string{"notes"}},
{name: "unconfigured profile", profile: "gone", wantErr: `"gone" is not configured`},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
p, err := c.Profile(tt.profile)
if tt.wantErr != "" {
if err == nil || !strings.Contains(err.Error(), tt.wantErr) {
t.Fatalf("Profile() error = %v, want containing %q", err, tt.wantErr)
}
return
}
if err != nil || p.Image != tt.wantImage || !slices.Equal(p.Tools, tt.wantTools) {
t.Fatalf("Profile() = %+v, %v; want image %q tools %v", p, err, tt.wantImage, tt.wantTools)
}
})
}
bad := ContainerConfig{Profiles: map[string]AgentProfile{"x": {Tools: []string{" "}}}}
if err := bad.ValidateProfiles(); err == nil {
t.Error("ValidateProfiles accepted an empty tool name")
}
}
func TestKitProfiles(t *testing.T) {
const pinned = "docker/claude-code-kit@sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
c := ContainerConfig{Image: "archie-agent:1", Profiles: map[string]AgentProfile{
"claude": {Kit: pinned, Adapter: "claude-code"},
}}
p, err := c.Profile("claude")
if err != nil || p.Image != "" || !p.IsKit() {
t.Fatalf("Profile() = %+v, %v; a Kit profile must not inherit the agent image", p, err)
}
for name, bad := range map[string]AgentProfile{
"image and kit": {Image: "archie-agent:1", Kit: pinned},
"unpinned kit": {Kit: "docker/claude-code-kit:latest"},
"adapter without a kit": {Adapter: "claude-code"},
} {
c := ContainerConfig{Profiles: map[string]AgentProfile{"p": bad}}
if err := c.ValidateProfiles(); err == nil {
t.Errorf("%s: ValidateProfiles accepted %+v", name, bad)
}
}
if err := c.ValidateProfiles(); err != nil {
t.Fatalf("a digest-pinned Kit profile was refused: %v", err)
}
}