Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/gitpod-cli/cmd/root_test.go
2498 views
1
// Copyright (c) 2023 Gitpod GmbH. All rights reserved.
2
// Licensed under the GNU Affero General Public License (AGPL).
3
// See License.AGPL.txt in the project root for license information.
4
5
package cmd
6
7
import (
8
"testing"
9
10
"github.com/google/go-cmp/cmp"
11
)
12
13
func TestGetCommandName(t *testing.T) {
14
tests := []struct {
15
Input string
16
Expectation []string
17
}{
18
{"gp", []string{}},
19
{"gp top", []string{"top"}},
20
{"gp tasks list", []string{"tasks", "list"}},
21
{"gp very nested command", []string{"very", "nested", "command"}},
22
}
23
24
for _, test := range tests {
25
t.Run(test.Input, func(t *testing.T) {
26
cmdName := GetCommandName(test.Input)
27
28
if diff := cmp.Diff(test.Expectation, cmdName); diff != "" {
29
t.Errorf("GetCommandName() mismatch (-want +got):\n%s", diff)
30
}
31
})
32
}
33
}
34
35