summaryrefslogtreecommitdiff
path: root/internal/command/commandargs/command_args_test.go
diff options
context:
space:
mode:
authorfeistel <6742251-feistel@users.noreply.gitlab.com>2021-08-11 17:29:02 +0000
committerfeistel <6742251-feistel@users.noreply.gitlab.com>2021-08-11 17:29:59 +0000
commitfa2cdbda42dc46428377e9d000e164f6fefd8da1 (patch)
treebc0044f0c1be58185d0574de7a0bb295825fc593 /internal/command/commandargs/command_args_test.go
parent7b44ce1d4a0716d27acabb4f826eb5613dade082 (diff)
downloadgitlab-shell-fa2cdbda42dc46428377e9d000e164f6fefd8da1.tar.gz
refactor: remove commandargs.GenericArgs
Diffstat (limited to 'internal/command/commandargs/command_args_test.go')
-rw-r--r--internal/command/commandargs/command_args_test.go17
1 files changed, 11 insertions, 6 deletions
diff --git a/internal/command/commandargs/command_args_test.go b/internal/command/commandargs/command_args_test.go
index 7b9f0ad..119ecd4 100644
--- a/internal/command/commandargs/command_args_test.go
+++ b/internal/command/commandargs/command_args_test.go
@@ -16,6 +16,7 @@ func TestParseSuccess(t *testing.T) {
env sshenv.Env
arguments []string
expectedArgs CommandArgs
+ expectError bool
}{
{
desc: "It sets discover as the command when the command string was empty",
@@ -100,10 +101,10 @@ func TestParseSuccess(t *testing.T) {
arguments: []string{"key", "principal-1", "principal-2"},
expectedArgs: &AuthorizedPrincipals{Arguments: []string{"key", "principal-1", "principal-2"}, KeyId: "key", Principals: []string{"principal-1", "principal-2"}},
}, {
- desc: "Unknown executable",
- executable: &executable.Executable{Name: "unknown"},
- arguments: []string{},
- expectedArgs: &GenericArgs{Arguments: []string{}},
+ desc: "Unknown executable",
+ executable: &executable.Executable{Name: "unknown"},
+ arguments: []string{},
+ expectError: true,
},
}
@@ -111,8 +112,12 @@ func TestParseSuccess(t *testing.T) {
t.Run(tc.desc, func(t *testing.T) {
result, err := Parse(tc.executable, tc.arguments, tc.env)
- require.NoError(t, err)
- require.Equal(t, tc.expectedArgs, result)
+ if !tc.expectError {
+ require.NoError(t, err)
+ require.Equal(t, tc.expectedArgs, result)
+ } else {
+ require.Error(t, err)
+ }
})
}
}