(t *testing.T)
| 271 | } |
| 272 | |
| 273 | func TestExtractRateLimitConfig(t *testing.T) { |
| 274 | c := &Compiler{} |
| 275 | |
| 276 | t.Run("extracts user-rate-limit config", func(t *testing.T) { |
| 277 | cfg := c.extractRateLimitConfig(map[string]any{ |
| 278 | "user-rate-limit": map[string]any{ |
| 279 | "max-runs-per-window": 3, |
| 280 | "window": 45, |
| 281 | "events": []any{"issue_comment"}, |
| 282 | "ignored-roles": []any{"admin"}, |
| 283 | }, |
| 284 | }) |
| 285 | |
| 286 | if assert.NotNil(t, cfg) { |
| 287 | assert.Equal(t, 3, cfg.Max) |
| 288 | assert.Equal(t, 45, cfg.Window) |
| 289 | assert.Equal(t, []string{"issue_comment"}, cfg.Events) |
| 290 | assert.Equal(t, []string{"admin"}, cfg.IgnoredRoles) |
| 291 | } |
| 292 | }) |
| 293 | |
| 294 | t.Run("legacy rate-limit key is ignored", func(t *testing.T) { |
| 295 | cfg := c.extractRateLimitConfig(map[string]any{ |
| 296 | "rate-limit": map[string]any{ |
| 297 | "max-runs": 3, |
| 298 | "window": 45, |
| 299 | }, |
| 300 | }) |
| 301 | |
| 302 | assert.Nil(t, cfg) |
| 303 | }) |
| 304 | } |
| 305 | |
| 306 | // TestCommentAuthorAssociationConditionInPreActivation verifies that the compiler adds |
| 307 | // an explicit author_association guard to the pre_activation job's if: condition when the |
nothing calls this directly
no test coverage detected