The pattern ended at the word, so control planes and flavors passed where control plane and flavor fail. It now takes s or es on the last part; a test holds it, and merge-check runs that test before the check.
27 lines
819 B
Go
27 lines
819 B
Go
package main
|
|
|
|
import "testing"
|
|
|
|
// A retired word's plural is the word; anything else joined on is another word.
|
|
func TestPatternMatchesTheWordAndItsPlural(t *testing.T) {
|
|
cases := []struct {
|
|
word, text string
|
|
want bool
|
|
}{
|
|
{"control plane", "ask the control plane", true},
|
|
{"control plane", "two control planes", true},
|
|
{"control plane", "two control\n\tplanes", true},
|
|
{"substrate", "the substrates", true},
|
|
{"flavor", "flavors of a module", true},
|
|
{"flavor", "flavored", false},
|
|
{"node tools", "node toolsets", false},
|
|
{"mesh-console", "the mesh-consoles", true},
|
|
{"mesh-console", "mesh-console-x", false},
|
|
}
|
|
for _, c := range cases {
|
|
if got := pattern(c.word).MatchString(c.text); got != c.want {
|
|
t.Errorf("pattern(%q) on %q = %v, want %v", c.word, c.text, got, c.want)
|
|
}
|
|
}
|
|
}
|