completion_test.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. Copyright 2017 The Kubernetes Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package kubeadm
  14. import "testing"
  15. func TestCmdCompletion(t *testing.T) {
  16. kubeadmPath := getKubeadmPath()
  17. if *kubeadmCmdSkip {
  18. t.Log("kubeadm cmd tests being skipped")
  19. t.Skip()
  20. }
  21. var tests = []struct {
  22. name string
  23. args string
  24. expected bool
  25. }{
  26. {"shell not expected", "", false},
  27. {"unsupported shell type", "foo", false},
  28. }
  29. for _, rt := range tests {
  30. t.Run(rt.name, func(t *testing.T) {
  31. _, _, _, actual := RunCmd(kubeadmPath, "completion", rt.args)
  32. if (actual == nil) != rt.expected {
  33. t.Errorf(
  34. "failed CmdCompletion running 'kubeadm completion %s' with an error: %v\n\texpected: %t\n\t actual: %t",
  35. rt.args,
  36. actual,
  37. rt.expected,
  38. (actual == nil),
  39. )
  40. }
  41. })
  42. }
  43. }