carlos / platform Public

Clone
git clone https://amadan.net/carlos/platform

Plain git — no account needed to clone.

Download

Download this file

1package hostbox
2
3import (
4 "context"
5 "testing"
6
7 "github.com/carlosframework/platform/internal/hostwrite"
8)
9
10// Only installWithWork's own selection is installation work (harness G10,
11// fix round 2): the mark is set on a copy of the selected work, never on the
12// original, and work of any other kind stays unmarked.
13func TestInstallationWorkMarksOnlyTheInstallationsSelection(t *testing.T) {
14 w := selectedWork{selection: Selection{Host: "shop.example", Action: "reconcile"}, checked: &checkedPhase{}}
15 if s, err := Selected(w); err != nil || s.Installation() {
16 t.Fatal("SelectAt's work is installation work before installWithWork marks it", s, err)
17 }
18 marked := installationWork(w)
19 if s, err := Selected(marked); err != nil || !s.Installation() || s.Host != "shop.example" || s.Action != "reconcile" {
20 t.Fatal("marked selection", s, err)
21 }
22 if s, _ := Selected(w); s.Installation() {
23 t.Fatal("the mark reached the original work")
24 }
25 other := hostwrite.Work(otherWork{})
26 if got := installationWork(other); got != other {
27 t.Fatal("non-selected work changed")
28 }
29 if (Selection{}).Installation() {
30 t.Fatal("a zero selection is installation work")
31 }
32}
33
34type otherWork struct{}
35
36func (otherWork) With(context.Context, hostwrite.Identity, func() error) error { return nil }
37