package skillpack import ( "context" "testing" ) func TestActivator(t *testing.T) { ctx := context.Background() src := &fakeSource{tree: packTree("alpha", "do alpha things"), ref: "r1"} y := newTestSyncer(src) if _, err := y.Subscribe(ctx, src, "main", "steve"); err != nil { t.Fatal(err) } staged := 0 act := &Activator{ Cache: y.Cache, Subs: y.Subs, StagerFor: func(runID, subjectID string) BundleStager { return func(context.Context, *Pack) (string, error) { staged++; return "", nil } }, } instr, tools, err := act.ActivateSkillPacks(ctx, []string{"alpha"}, "run1", "agent1") if err != nil { t.Fatal(err) } if instr == "" { t.Error("expected catalog instructions") } found := false for _, tl := range tools { if tl.Name == "skill_use" { found = true } } if !found { t.Errorf("expected a skill_use tool, got %d tools", len(tools)) } // unknown name → nothing resolves (no error, no tools). if in, tl, err := act.ActivateSkillPacks(ctx, []string{"nope"}, "r", "a"); err != nil || in != "" || tl != nil { t.Fatalf("unknown pack should resolve to nothing: in=%q tools=%v err=%v", in, tl, err) } // nil-safe: a zero Activator (or empty names) is inert. if in, tl, err := (&Activator{}).ActivateSkillPacks(ctx, []string{"alpha"}, "r", "a"); err != nil || in != "" || tl != nil { t.Fatalf("zero Activator should be inert: %q %v %v", in, tl, err) } }