//go:build integration package main import ( "errors" "strings" "testing" ) func TestUnreadableConditionsAreNotAWellMesh(t *testing.T) { open := aMesh(t) _, store := withConditionsInMemory(t) store.SetFail(errors.New("the bus is away")) asked, err := theThreeQuestions(t.Context(), open) if err != nil { t.Fatal(err) } if asked.well() || asked.conditionsUnread == "" { t.Fatalf("well with its conditions unread: %+v", asked.conditionsUnread) } said := printed(t, func() error { return printStatus(asked) }) if !strings.HasPrefix(said, "the open conditions could NOT be read") || strings.Contains(said, "no open conditions") { t.Fatalf("%s", said) } store.SetFail(nil) asked, _ = theThreeQuestions(t.Context(), open) said = printed(t, func() error { return printStatus(asked) }) if asked.well() && !strings.Contains(said, "no open conditions;") { t.Fatalf("the all-well sentence does not say no conditions are open:\n%s", said) } }