mirror of
https://github.com/lukaszraczylo/git-velocity.git
synced 2026-06-26 04:42:57 +00:00
Fix filtering out the bot activity.
This commit is contained in:
@@ -615,15 +615,10 @@ func TestConfig_GetTeamForUser(t *testing.T) {
|
||||
func TestConfig_IsBot(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
// Bot patterns are now hardcoded, so we just need IncludeBots: false
|
||||
cfg := &Config{
|
||||
Options: OptionsConfig{
|
||||
IncludeBots: false,
|
||||
BotPatterns: []string{
|
||||
"*[bot]",
|
||||
"dependabot*",
|
||||
"renovate*",
|
||||
"github-actions*",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -652,6 +647,16 @@ func TestConfig_IsBot(t *testing.T) {
|
||||
username: "github-actions[bot]",
|
||||
expected: true,
|
||||
},
|
||||
{
|
||||
name: "codecov bot (hardcoded)",
|
||||
username: "codecov[bot]",
|
||||
expected: true,
|
||||
},
|
||||
{
|
||||
name: "snyk bot (hardcoded)",
|
||||
username: "snyk-bot",
|
||||
expected: true,
|
||||
},
|
||||
{
|
||||
name: "regular user",
|
||||
username: "alice",
|
||||
@@ -674,19 +679,43 @@ func TestConfig_IsBot(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestConfig_IsBot_AdditionalPatterns(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
cfg := &Config{
|
||||
Options: OptionsConfig{
|
||||
IncludeBots: false,
|
||||
AdditionalBotPatterns: []string{"my-custom-bot", "ci-*"},
|
||||
},
|
||||
}
|
||||
|
||||
// Custom patterns should work
|
||||
assert.True(t, cfg.IsBot("my-custom-bot"))
|
||||
assert.True(t, cfg.IsBot("ci-runner"))
|
||||
assert.True(t, cfg.IsBot("ci-bot"))
|
||||
|
||||
// Hardcoded patterns should still work
|
||||
assert.True(t, cfg.IsBot("dependabot[bot]"))
|
||||
assert.True(t, cfg.IsBot("renovate[bot]"))
|
||||
|
||||
// Regular users should not match
|
||||
assert.False(t, cfg.IsBot("alice"))
|
||||
}
|
||||
|
||||
func TestConfig_IsBot_IncludeBots(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
cfg := &Config{
|
||||
Options: OptionsConfig{
|
||||
IncludeBots: true,
|
||||
BotPatterns: []string{"*[bot]"},
|
||||
},
|
||||
}
|
||||
|
||||
// When IncludeBots is true, nothing should be considered a bot
|
||||
// (even hardcoded patterns are bypassed)
|
||||
assert.False(t, cfg.IsBot("my-app[bot]"))
|
||||
assert.False(t, cfg.IsBot("dependabot"))
|
||||
assert.False(t, cfg.IsBot("renovate[bot]"))
|
||||
}
|
||||
|
||||
func TestMatchPattern(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user