mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-05 07:27:21 +00:00
Fixes get --show-all
This commit is contained in:
@@ -1003,3 +1003,61 @@ func TestReplaceAliases(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestHasNames(t *testing.T) {
|
||||
tests := []struct {
|
||||
args []string
|
||||
expectedHasName bool
|
||||
expectedError error
|
||||
}{
|
||||
{
|
||||
args: []string{""},
|
||||
expectedHasName: false,
|
||||
expectedError: nil,
|
||||
},
|
||||
{
|
||||
args: []string{"rc"},
|
||||
expectedHasName: false,
|
||||
expectedError: nil,
|
||||
},
|
||||
{
|
||||
args: []string{"rc,pod,svc"},
|
||||
expectedHasName: false,
|
||||
expectedError: nil,
|
||||
},
|
||||
{
|
||||
args: []string{"rc/foo"},
|
||||
expectedHasName: true,
|
||||
expectedError: nil,
|
||||
},
|
||||
{
|
||||
args: []string{"rc", "foo"},
|
||||
expectedHasName: true,
|
||||
expectedError: nil,
|
||||
},
|
||||
{
|
||||
args: []string{"rc,pod,svc", "foo"},
|
||||
expectedHasName: true,
|
||||
expectedError: nil,
|
||||
},
|
||||
{
|
||||
args: []string{"rc/foo", "rc/bar", "rc/zee"},
|
||||
expectedHasName: true,
|
||||
expectedError: nil,
|
||||
},
|
||||
{
|
||||
args: []string{"rc/foo", "bar"},
|
||||
expectedHasName: false,
|
||||
expectedError: fmt.Errorf("when passing arguments in resource/name form, all arguments must include the resource"),
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
hasNames, err := HasNames(test.args)
|
||||
if !reflect.DeepEqual(test.expectedError, err) {
|
||||
t.Errorf("expected HasName to error %v, got %s", test.expectedError, err)
|
||||
}
|
||||
if hasNames != test.expectedHasName {
|
||||
t.Errorf("expected HasName to return %v for %s", test.expectedHasName, test.args)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user