package main import ( "strings" "testing" "github.com/kami/maven/internal/morning" ) // TestMorningNudgeBodySeparatesOptional — the one message a routine is allowed // per day says what was not done, then what he could still do (Vikunja #473). func TestMorningNudgeBodySeparatesOptional(t *testing.T) { cand := morning.Candidate{ Routine: morning.Routine{Name: "утро"}, Missing: []morning.Item{ {Key: "meds", Label: "таблетки"}, {Key: "stretch", Label: "растяжка", Optional: true}, }, } body := morningNudgeBody(cand) if !strings.Contains(body, "не сделано — таблетки") { t.Fatalf("the required item must be named as not done: %q", body) } if !strings.Contains(body, "если будет время — растяжка") { t.Fatalf("the optional item must read softer: %q", body) } if strings.Contains(body, "не сделано — таблетки, растяжка") { t.Fatalf("optional must not be folded into the required list: %q", body) } // Nothing optional missing: the sentence is what it always was. only := morning.Candidate{ Routine: morning.Routine{Name: "утро"}, Missing: []morning.Item{{Key: "meds", Label: "таблетки"}}, } if got, want := morningNudgeBody(only), "утро: не сделано — таблетки"; got != want { t.Fatalf("morningNudgeBody = %q, want %q", got, want) } }