gitea-sonarqube-bot/internal/actions/actions_test.go
justusbunsi 8a7e9f83fa
Refactor action validation
Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2021-10-17 11:12:50 +02:00

18 lines
600 B
Go

package actions
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestIsValidBotCommentForInvalidComment(t *testing.T) {
assert.False(t, IsValidBotComment(""), "Undetected missing action prefix")
assert.False(t, IsValidBotComment("/sq-bot invalid-command"), "Undetected invalid bot command")
assert.False(t, IsValidBotComment("Some context with /sq-bot review within"), "Incorrect bot prefix detected inside random comment")
}
func TestIsValidBotCommentForValidComment(t *testing.T) {
assert.True(t, IsValidBotComment("/sq-bot review"), "Correct bot comment not recognized")
}