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

Function TestParseIssueDiscussionTriggers

pkg/workflow/trigger_parser_test.go:450–524  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

448}
449
450func TestParseIssueDiscussionTriggers(t *testing.T) {
451 tests := []struct {
452 name string
453 input string
454 wantEvent string
455 wantTypes []string
456 wantErr bool
457 }{
458 {
459 name: "issue assigned",
460 input: "issue assigned",
461 wantEvent: "issues",
462 wantTypes: []string{"assigned"},
463 },
464 {
465 name: "issue unassigned",
466 input: "issue unassigned",
467 wantEvent: "issues",
468 wantTypes: []string{"unassigned"},
469 },
470 {
471 name: "discussion answered",
472 input: "discussion answered",
473 wantEvent: "discussion",
474 wantTypes: []string{"answered"},
475 },
476 {
477 name: "discussion unanswered",
478 input: "discussion unanswered",
479 wantEvent: "discussion",
480 wantTypes: []string{"unanswered"},
481 },
482 {
483 name: "invalid issue type",
484 input: "issue invalid",
485 wantErr: true,
486 },
487 {
488 name: "invalid discussion type",
489 input: "discussion invalid",
490 wantErr: true,
491 },
492 }
493
494 for _, tt := range tests {
495 t.Run(tt.name, func(t *testing.T) {
496 ir, err := ParseTriggerShorthand(tt.input)
497
498 if tt.wantErr {
499 if err == nil {
500 t.Errorf("ParseTriggerShorthand() expected error but got none")
501 }
502 return
503 }
504
505 if err != nil {
506 t.Errorf("ParseTriggerShorthand() unexpected error = %v", err)
507 return

Callers

nothing calls this directly

Calls 4

ParseTriggerShorthandFunction · 0.85
slicesEqualFunction · 0.85
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected