MCPcopy Create free account
hub / github.com/github/gh-aw / TestExtractRateLimitConfig

Function TestExtractRateLimitConfig

pkg/workflow/role_checks_test.go:273–304  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

271}
272
273func 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

Callers

nothing calls this directly

Calls 2

RunMethod · 0.45

Tested by

no test coverage detected