dco-go/main_test.go
Evgenii Stratonikov b8aea16a20 [#2] Write tests for the regex
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
2024-01-25 19:17:12 +03:00

30 lines
698 B
Go

package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestCommitMessages(t *testing.T) {
allowed := []string{
"[#1] omg: Make a commit",
"[#666] Omit component",
`Revert "[#114] local: Fix payload type after recent refactoring"`,
`Reapply "[#114] local: Fix payload type after recent refactoring"`,
`Release v0.4.2`,
}
for i := range allowed {
assert.True(t, rxHeader.MatchString(allowed[i]), "message: '%s'", allowed[i])
}
restricted := []string{
"[#xx] omg: Forget numbers",
"#12 Forget brackets",
"Refactor something",
}
for i := range restricted {
assert.False(t, rxHeader.MatchString(restricted[i]), "message: '%s'", restricted[i])
}
}