Skip to content
quarry Artifact [46291c047a]
Login

Artifact [46291c047a]

Artifact 46291c047a9d819d13023a2255934b6c39e572f2b4ad0ebc1375af741a40a30c:


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)
		}
	}
}