flags_test.go 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. Copyright 2014 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 unversioned
  14. import (
  15. "testing"
  16. "time"
  17. "k8s.io/kubernetes/pkg/util/sets"
  18. )
  19. type fakeFlagSet struct {
  20. t *testing.T
  21. set sets.String
  22. }
  23. func (f *fakeFlagSet) StringVar(p *string, name, value, usage string) {
  24. if p == nil {
  25. f.t.Errorf("unexpected nil pointer")
  26. }
  27. if usage == "" {
  28. f.t.Errorf("unexpected empty usage")
  29. }
  30. f.set.Insert(name)
  31. }
  32. func (f *fakeFlagSet) BoolVar(p *bool, name string, value bool, usage string) {
  33. if p == nil {
  34. f.t.Errorf("unexpected nil pointer")
  35. }
  36. if usage == "" {
  37. f.t.Errorf("unexpected empty usage")
  38. }
  39. f.set.Insert(name)
  40. }
  41. func (f *fakeFlagSet) UintVar(p *uint, name string, value uint, usage string) {
  42. if p == nil {
  43. f.t.Errorf("unexpected nil pointer")
  44. }
  45. if usage == "" {
  46. f.t.Errorf("unexpected empty usage")
  47. }
  48. f.set.Insert(name)
  49. }
  50. func (f *fakeFlagSet) DurationVar(p *time.Duration, name string, value time.Duration, usage string) {
  51. if p == nil {
  52. f.t.Errorf("unexpected nil pointer")
  53. }
  54. if usage == "" {
  55. f.t.Errorf("unexpected empty usage")
  56. }
  57. f.set.Insert(name)
  58. }
  59. func (f *fakeFlagSet) IntVar(p *int, name string, value int, usage string) {
  60. if p == nil {
  61. f.t.Errorf("unexpected nil pointer")
  62. }
  63. if usage == "" {
  64. f.t.Errorf("unexpected empty usage")
  65. }
  66. f.set.Insert(name)
  67. }