From be4a99dede5421a2356489d8ce438cc39caee555 Mon Sep 17 00:00:00 2001 From: "devsy-app[bot]" <277138668+devsy-app[bot]@users.noreply.github.com> Date: Sun, 16 Aug 2026 10:26:19 +0000 Subject: [PATCH 1/2] test(command): cover Quote escape behavior Add table-driven test for pkg/command Quote covering empty, single-arg passthrough, multi-arg join, and special-char escaping. --- pkg/command/escape_test.go | 49 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 pkg/command/escape_test.go diff --git a/pkg/command/escape_test.go b/pkg/command/escape_test.go new file mode 100644 index 000000000..4a20b359a --- /dev/null +++ b/pkg/command/escape_test.go @@ -0,0 +1,49 @@ +package command + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestQuote(t *testing.T) { + cases := []struct { + name string + args []string + want string + }{ + {name: "empty returns empty", args: nil, want: ""}, + {name: "empty slice returns empty", args: []string{}, want: ""}, + { + name: "single arg passed through unquoted", + args: []string{"devsy-linux-amd64"}, + want: "devsy-linux-amd64", + }, + { + name: "single arg with spaces passed through unchanged", + args: []string{"agent internal ssh-git-clone"}, + want: "agent internal ssh-git-clone", + }, + { + name: "multiple args are shell-quoted and joined", + args: []string{"agent", "internal", "ssh-git-clone"}, + want: "agent internal ssh-git-clone", + }, + { + name: "arg needing escaping is single-quoted", + args: []string{"agent", "--key-file=/tmp/my key"}, + want: "agent '--key-file=/tmp/my key'", + }, + { + name: "embedded single quote is escaped", + args: []string{"echo", "it's"}, + want: "echo 'it'\"'\"'s'", + }, + } + + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + assert.Equal(t, tc.want, Quote(tc.args)) + }) + } +} From f22ce9e8f586d7585f2822ec349ac97670777178 Mon Sep 17 00:00:00 2001 From: Samuel K Date: Mon, 17 Aug 2026 05:39:36 +0000 Subject: [PATCH 2/2] refactor: extract constant Signed-off-by: Samuel K --- pkg/command/escape_test.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/command/escape_test.go b/pkg/command/escape_test.go index 4a20b359a..87f4ef37e 100644 --- a/pkg/command/escape_test.go +++ b/pkg/command/escape_test.go @@ -6,6 +6,8 @@ import ( "github.com/stretchr/testify/assert" ) +const agentInternalSSHGitClone = "agent internal ssh-git-clone" + func TestQuote(t *testing.T) { cases := []struct { name string @@ -21,13 +23,13 @@ func TestQuote(t *testing.T) { }, { name: "single arg with spaces passed through unchanged", - args: []string{"agent internal ssh-git-clone"}, - want: "agent internal ssh-git-clone", + args: []string{agentInternalSSHGitClone}, + want: agentInternalSSHGitClone, }, { name: "multiple args are shell-quoted and joined", args: []string{"agent", "internal", "ssh-git-clone"}, - want: "agent internal ssh-git-clone", + want: agentInternalSSHGitClone, }, { name: "arg needing escaping is single-quoted",