package hostbox import ( "context" "testing" "github.com/carlosframework/platform/internal/hostwrite" ) // Only installWithWork's own selection is installation work (harness G10, // fix round 2): the mark is set on a copy of the selected work, never on the // original, and work of any other kind stays unmarked. func TestInstallationWorkMarksOnlyTheInstallationsSelection(t *testing.T) { w := selectedWork{selection: Selection{Host: "shop.example", Action: "reconcile"}, checked: &checkedPhase{}} if s, err := Selected(w); err != nil || s.Installation() { t.Fatal("SelectAt's work is installation work before installWithWork marks it", s, err) } marked := installationWork(w) if s, err := Selected(marked); err != nil || !s.Installation() || s.Host != "shop.example" || s.Action != "reconcile" { t.Fatal("marked selection", s, err) } if s, _ := Selected(w); s.Installation() { t.Fatal("the mark reached the original work") } other := hostwrite.Work(otherWork{}) if got := installationWork(other); got != other { t.Fatal("non-selected work changed") } if (Selection{}).Installation() { t.Fatal("a zero selection is installation work") } } type otherWork struct{} func (otherWork) With(context.Context, hostwrite.Identity, func() error) error { return nil }