The board says what is waiting too, or it disagrees with the command
Adding "not running what the mesh would send it" to `status` and not to the board would have left two answers to one question with a person in front of each — which is the single thing this page's design forbids, introduced by the change that was supposed to make the question answerable. The published JSON carries it as well, so the page, the command and anything built against either say the same thing from the same read. Additive, because that shape is hard to change once anything is built against it. Never told stays separate from out of date on the page as it is everywhere else: same remedy, and nobody has ever asked that machine to be anything.
This commit is contained in:
@@ -119,3 +119,36 @@ func render(t *testing.T, v view) string {
|
||||
}
|
||||
return out.String()
|
||||
}
|
||||
|
||||
// The board and the command must answer the same question the same way.
|
||||
//
|
||||
// A machine not running what the mesh would send it was added to `status` and would have been
|
||||
// missing here — which is the one thing this page's design forbids: two answers to the same
|
||||
// question, disagreeing, with a person in front of each.
|
||||
func TestTheBoardSaysWhichMachinesHaveNotBeenSentWhatTheyShouldBe(t *testing.T) {
|
||||
rendered := render(t, viewOf(answers{
|
||||
nodes: []inventory.Node{{Name: "anchor"}, {Name: "laptop"}},
|
||||
waiting: []inventory.Machine{
|
||||
{Node: "anchor"},
|
||||
{Node: "laptop", Never: true},
|
||||
},
|
||||
}))
|
||||
if !strings.Contains(rendered, "is not running what the mesh would send it") {
|
||||
t.Fatalf("the page does not say a machine is out of date:\n%s", rendered)
|
||||
}
|
||||
// Never told is a different situation with the same remedy, and the page keeps them apart.
|
||||
if !strings.Contains(rendered, "has never been sent anything") {
|
||||
t.Fatalf("the page does not separate never told from out of date:\n%s", rendered)
|
||||
}
|
||||
if !strings.Contains(rendered, "push --behind") {
|
||||
t.Fatalf("the page does not say what sends them:\n%s", rendered)
|
||||
}
|
||||
}
|
||||
|
||||
// And says so when there is nothing waiting, rather than leaving the question unanswered.
|
||||
func TestAMeshWithNothingWaitingSaysSo(t *testing.T) {
|
||||
rendered := render(t, viewOf(answers{nodes: []inventory.Node{{Name: "anchor"}}}))
|
||||
if !strings.Contains(rendered, "Every machine is running what the mesh would send it") {
|
||||
t.Fatalf("the page leaves the question unanswered:\n%s", rendered)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user