package operator_test import ( "slices" "testing" "testing/synctest" "k8s.io/apimachinery/pkg/util/validation" "tangled.org/guid.foo/simmer/api/v1alpha1" "tangled.org/guid.foo/simmer/dataplane" "tangled.org/guid.foo/simmer/internal/world" ) // A duty that names a plugin's skill starts a Session whose labels the // API server accepts, and its turn carries the Mandate's plugins. func TestADutyOfAPluginsSkillRunsWithThePlugins(t *testing.T) { synctest.Test(t, func(t *testing.T) { m := ops() m.Spec.Tools.Plugins = []string{"ssh://git@forge.example/owner/shop.git"} r := startWith(t, roomy(), m, world.When(m, "shop:triage", "alerts", "firing")) r.pass(t) r.pass(t) s := r.only(t) turn, err := r.o.Turn(t.Context(), dataplane.SessionRef{Namespace: "telemetry", Name: s.Metadata.Name}) if problems := validation.IsValidLabelValue(s.Metadata.Labels[v1alpha1.LabelDuty]); len(problems) > 0 { t.Errorf("the duty label %q is not a label value: %v", s.Metadata.Labels[v1alpha1.LabelDuty], problems) } if err != nil || turn.Skill != "shop:triage" || !slices.Equal(turn.Plugins, m.Spec.Tools.Plugins) { t.Errorf("turn = %+v, %v; want shop:triage with the plugin", turn, err) } }) }