From debf0bbaf22b7293da97b10d0ad01f1c64e05904 Mon Sep 17 00:00:00 2001 From: Kynan Ware <47394200+BagToad@users.noreply.github.com> Date: Fri, 16 May 2025 09:50:24 -0600 Subject: [PATCH] test(params): enhance Copilot replacer tests for edge cases - Added tests for handling nil and empty slices in the Copilot replacer. - Simplified test structure by removing unnecessary wantErr field. --- pkg/cmd/pr/shared/params_test.go | 33 ++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/pkg/cmd/pr/shared/params_test.go b/pkg/cmd/pr/shared/params_test.go index 4a353e97e..53eb6328f 100644 --- a/pkg/cmd/pr/shared/params_test.go +++ b/pkg/cmd/pr/shared/params_test.go @@ -192,42 +192,51 @@ func TestCopilotReplacer_ReplaceSlice(t *testing.T) { handles []string } tests := []struct { - name string - args args - want []string - wantErr bool + name string + args args + want []string }{ { name: "replaces @copilot with copilot-swe-agent", args: args{ handles: []string{"monalisa", "@copilot", "hubot"}, }, - want: []string{"monalisa", "copilot-swe-agent", "hubot"}, - wantErr: false, + want: []string{"monalisa", "copilot-swe-agent", "hubot"}, }, { name: "handles no @copilot mentions", args: args{ handles: []string{"monalisa", "user", "hubot"}, }, - want: []string{"monalisa", "user", "hubot"}, - wantErr: false, + want: []string{"monalisa", "user", "hubot"}, }, { name: "replaces multiple @copilot mentions", args: args{ handles: []string{"@copilot", "user", "@copilot"}, }, - want: []string{"copilot-swe-agent", "user", "copilot-swe-agent"}, - wantErr: false, + want: []string{"copilot-swe-agent", "user", "copilot-swe-agent"}, }, { name: "handles @copilot case-insensitively", args: args{ handles: []string{"@Copilot", "user", "@CoPiLoT"}, }, - want: []string{"copilot-swe-agent", "user", "copilot-swe-agent"}, - wantErr: false, + want: []string{"copilot-swe-agent", "user", "copilot-swe-agent"}, + }, + { + name: "handles nil slice", + args: args{ + handles: nil, + }, + want: []string{}, + }, + { + name: "handles empty slice", + args: args{ + handles: []string{}, + }, + want: []string{}, }, } for _, tt := range tests {