package agent import ( "context" "log/slog" "path/filepath" "testing" "git.wntrmute.dev/mc/mcp/internal/config" "git.wntrmute.dev/mc/mcp/internal/registry" "git.wntrmute.dev/mc/mcp/internal/runtime" ) // fakeRuntime implements runtime.Runtime for testing. type fakeRuntime struct { containers []runtime.ContainerInfo inspectMap map[string]runtime.ContainerInfo listErr error } func (f *fakeRuntime) Pull(_ context.Context, _ string) error { return nil } func (f *fakeRuntime) Run(_ context.Context, _ runtime.ContainerSpec) error { return nil } func (f *fakeRuntime) Stop(_ context.Context, _ string) error { return nil } func (f *fakeRuntime) Remove(_ context.Context, _ string) error { return nil } func (f *fakeRuntime) Build(_ context.Context, _, _, _ string) error { return nil } func (f *fakeRuntime) Push(_ context.Context, _ string) error { return nil } func (f *fakeRuntime) ImageExists(_ context.Context, _ string) (bool, error) { return true, nil } func (f *fakeRuntime) List(_ context.Context) ([]runtime.ContainerInfo, error) { return f.containers, f.listErr } func (f *fakeRuntime) Inspect(_ context.Context, name string) (runtime.ContainerInfo, error) { if f.inspectMap != nil { if info, ok := f.inspectMap[name]; ok { return info, nil } } for _, c := range f.containers { if c.Name == name { return c, nil } } return runtime.ContainerInfo{}, nil } // newTestAgent creates an Agent with a temp database for testing. func newTestAgent(t *testing.T, rt runtime.Runtime) *Agent { t.Helper() db, err := registry.Open(filepath.Join(t.TempDir(), "test.db")) if err != nil { t.Fatalf("open test db: %v", err) } t.Cleanup(func() { _ = db.Close() }) return &Agent{ Config: &config.AgentConfig{ Agent: config.AgentSettings{NodeName: "test-node"}, }, DB: db, Runtime: rt, Logger: slog.Default(), } }