gitea-sonarqube-bot/internal/actions/actions_test.go
justusbunsi 54beca9c25
Introduce better test case structure
Signed-off-by: Steven Kriegler <sk.bunsenbrenner@gmail.com>
2022-07-12 11:20:08 +02:00

20 lines
611 B
Go

package actions
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestIsValidBotComment(t *testing.T) {
t.Run("Valid", func(t *testing.T) {
assert.True(t, IsValidBotComment("/sq-bot review"), "Correct bot comment not recognized")
})
t.Run("Invalid", func(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")
})
}