Skip to content

Commit f7437f4

Browse files
Add missing Go compiler tests for safe-output types (#21617)
Add 14 missing test cases to TestAddHandlerManagerConfigEnvVar for safe-output types that lacked coverage in the compiler test file: - update_discussion - close_discussion - mark_pull_request_as_ready_for_review - create_pull_request_review_comment - autofix_code_scanning_alert - add_reviewer - assign_milestone - assign_to_agent - upload_asset - update_release - create_agent_session - hide_comment - set_issue_type - noop All test workflow files in pkg/cli/workflows/ already had coverage. Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent aa42df7 commit f7437f4

File tree

1 file changed

+217
-0
lines changed

1 file changed

+217
-0
lines changed

pkg/workflow/compiler_safe_outputs_config_test.go

Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,223 @@ func TestAddHandlerManagerConfigEnvVar(t *testing.T) {
449449
checkJSON: true,
450450
expectedKeys: []string{"dispatch_workflow"},
451451
},
452+
{
453+
name: "update_discussion config",
454+
safeOutputs: &SafeOutputsConfig{
455+
UpdateDiscussions: &UpdateDiscussionsConfig{
456+
UpdateEntityConfig: UpdateEntityConfig{
457+
BaseSafeOutputConfig: BaseSafeOutputConfig{
458+
Max: strPtr("1"),
459+
},
460+
},
461+
Title: testBoolPtr(true),
462+
Body: testBoolPtr(true),
463+
},
464+
},
465+
checkContains: []string{
466+
"GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG",
467+
},
468+
checkJSON: true,
469+
expectedKeys: []string{"update_discussion"},
470+
},
471+
{
472+
name: "close_discussion config",
473+
safeOutputs: &SafeOutputsConfig{
474+
CloseDiscussions: &CloseEntityConfig{
475+
BaseSafeOutputConfig: BaseSafeOutputConfig{
476+
Max: strPtr("5"),
477+
},
478+
},
479+
},
480+
checkContains: []string{
481+
"GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG",
482+
},
483+
checkJSON: true,
484+
expectedKeys: []string{"close_discussion"},
485+
},
486+
{
487+
name: "mark_pull_request_as_ready_for_review config",
488+
safeOutputs: &SafeOutputsConfig{
489+
MarkPullRequestAsReadyForReview: &MarkPullRequestAsReadyForReviewConfig{
490+
BaseSafeOutputConfig: BaseSafeOutputConfig{
491+
Max: strPtr("1"),
492+
},
493+
},
494+
},
495+
checkContains: []string{
496+
"GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG",
497+
},
498+
checkJSON: true,
499+
expectedKeys: []string{"mark_pull_request_as_ready_for_review"},
500+
},
501+
{
502+
name: "create_pull_request_review_comment config",
503+
safeOutputs: &SafeOutputsConfig{
504+
CreatePullRequestReviewComments: &CreatePullRequestReviewCommentsConfig{
505+
BaseSafeOutputConfig: BaseSafeOutputConfig{
506+
Max: strPtr("10"),
507+
},
508+
},
509+
},
510+
checkContains: []string{
511+
"GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG",
512+
},
513+
checkJSON: true,
514+
expectedKeys: []string{"create_pull_request_review_comment"},
515+
},
516+
{
517+
name: "autofix_code_scanning_alert config",
518+
safeOutputs: &SafeOutputsConfig{
519+
AutofixCodeScanningAlert: &AutofixCodeScanningAlertConfig{
520+
BaseSafeOutputConfig: BaseSafeOutputConfig{
521+
Max: strPtr("10"),
522+
},
523+
},
524+
},
525+
checkContains: []string{
526+
"GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG",
527+
},
528+
checkJSON: true,
529+
expectedKeys: []string{"autofix_code_scanning_alert"},
530+
},
531+
{
532+
name: "add_reviewer config",
533+
safeOutputs: &SafeOutputsConfig{
534+
AddReviewer: &AddReviewerConfig{
535+
BaseSafeOutputConfig: BaseSafeOutputConfig{
536+
Max: strPtr("3"),
537+
},
538+
},
539+
},
540+
checkContains: []string{
541+
"GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG",
542+
},
543+
checkJSON: true,
544+
expectedKeys: []string{"add_reviewer"},
545+
},
546+
{
547+
name: "assign_milestone config",
548+
safeOutputs: &SafeOutputsConfig{
549+
AssignMilestone: &AssignMilestoneConfig{
550+
BaseSafeOutputConfig: BaseSafeOutputConfig{
551+
Max: strPtr("1"),
552+
},
553+
},
554+
},
555+
checkContains: []string{
556+
"GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG",
557+
},
558+
checkJSON: true,
559+
expectedKeys: []string{"assign_milestone"},
560+
},
561+
{
562+
name: "assign_to_agent config",
563+
safeOutputs: &SafeOutputsConfig{
564+
AssignToAgent: &AssignToAgentConfig{
565+
BaseSafeOutputConfig: BaseSafeOutputConfig{
566+
Max: strPtr("1"),
567+
},
568+
DefaultAgent: "copilot",
569+
},
570+
},
571+
checkContains: []string{
572+
"GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG",
573+
},
574+
checkJSON: true,
575+
expectedKeys: []string{"assign_to_agent"},
576+
},
577+
{
578+
name: "upload_asset config",
579+
safeOutputs: &SafeOutputsConfig{
580+
UploadAssets: &UploadAssetsConfig{
581+
BaseSafeOutputConfig: BaseSafeOutputConfig{
582+
Max: strPtr("5"),
583+
},
584+
},
585+
},
586+
checkContains: []string{
587+
"GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG",
588+
},
589+
checkJSON: true,
590+
expectedKeys: []string{"upload_asset"},
591+
},
592+
{
593+
name: "update_release config",
594+
safeOutputs: &SafeOutputsConfig{
595+
UpdateRelease: &UpdateReleaseConfig{
596+
UpdateEntityConfig: UpdateEntityConfig{
597+
BaseSafeOutputConfig: BaseSafeOutputConfig{
598+
Max: strPtr("1"),
599+
},
600+
},
601+
},
602+
},
603+
checkContains: []string{
604+
"GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG",
605+
},
606+
checkJSON: true,
607+
expectedKeys: []string{"update_release"},
608+
},
609+
{
610+
name: "create_agent_session config",
611+
safeOutputs: &SafeOutputsConfig{
612+
CreateAgentSessions: &CreateAgentSessionConfig{
613+
BaseSafeOutputConfig: BaseSafeOutputConfig{
614+
Max: strPtr("1"),
615+
},
616+
},
617+
},
618+
checkContains: []string{
619+
"GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG",
620+
},
621+
checkJSON: true,
622+
expectedKeys: []string{"create_agent_session"},
623+
},
624+
{
625+
name: "hide_comment config",
626+
safeOutputs: &SafeOutputsConfig{
627+
HideComment: &HideCommentConfig{
628+
BaseSafeOutputConfig: BaseSafeOutputConfig{
629+
Max: strPtr("5"),
630+
},
631+
},
632+
},
633+
checkContains: []string{
634+
"GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG",
635+
},
636+
checkJSON: true,
637+
expectedKeys: []string{"hide_comment"},
638+
},
639+
{
640+
name: "set_issue_type config",
641+
safeOutputs: &SafeOutputsConfig{
642+
SetIssueType: &SetIssueTypeConfig{
643+
BaseSafeOutputConfig: BaseSafeOutputConfig{
644+
Max: strPtr("1"),
645+
},
646+
},
647+
},
648+
checkContains: []string{
649+
"GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG",
650+
},
651+
checkJSON: true,
652+
expectedKeys: []string{"set_issue_type"},
653+
},
654+
{
655+
name: "noop config",
656+
safeOutputs: &SafeOutputsConfig{
657+
NoOp: &NoOpConfig{
658+
BaseSafeOutputConfig: BaseSafeOutputConfig{
659+
Max: strPtr("1"),
660+
},
661+
},
662+
},
663+
checkContains: []string{
664+
"GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG",
665+
},
666+
checkJSON: true,
667+
expectedKeys: []string{"noop"},
668+
},
452669
}
453670

454671
for _, tt := range tests {

0 commit comments

Comments
 (0)