package ops
import (
"errors"
"fmt"
"testing"
)
// A reader sees the sentence the op wrote, not the category it was
// filed under: an auto-land waiting on CI read "...: forbidden", which
// looks like a permission problem.
func TestSentenceDropsTheCategory(t *testing.T) {
for _, c := range []struct {
err error
want string
}{
{fmt.Errorf("required checks not green: quarry, race: %w", ErrForbidden), "required checks not green: quarry, race"},
{fmt.Errorf("no ticket #9 here: %w", ErrNotFound), "no ticket #9 here"},
{fmt.Errorf("a title is required: %w", ErrInvalid), "a title is required"},
{ErrStarting, "still starting"},
// Only a category the error is: a sentence that merely ends in
// the same words is left alone.
{errors.New("the branch is forbidden"), "the branch is forbidden"},
{errors.New("plain failure"), "plain failure"},
} {
if got := Sentence(c.err); got != c.want {
t.Errorf("FAIL: Sentence(%q) = %q, want %q", c.err, got, c.want)
}
}
}