mock_threshold_notifier_test.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. Copyright 2018 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 eviction
  14. import (
  15. mock "github.com/stretchr/testify/mock"
  16. statsapi "k8s.io/kubernetes/pkg/kubelet/apis/stats/v1alpha1"
  17. )
  18. // MockCgroupNotifier is a mock implementation of the CgroupNotifier interface
  19. type MockCgroupNotifier struct {
  20. mock.Mock
  21. }
  22. // Start implements the NotifierFactory interface
  23. func (m *MockCgroupNotifier) Start(a0 chan<- struct{}) {
  24. m.Called(a0)
  25. }
  26. // Stop implements the NotifierFactory interface
  27. func (m *MockCgroupNotifier) Stop() {
  28. m.Called()
  29. }
  30. // MockNotifierFactory is a mock of the NotifierFactory interface
  31. type MockNotifierFactory struct {
  32. mock.Mock
  33. }
  34. // NewCgroupNotifier implements the NotifierFactory interface
  35. func (m *MockNotifierFactory) NewCgroupNotifier(a0, a1 string, a2 int64) (CgroupNotifier, error) {
  36. ret := m.Called(a0, a1, a2)
  37. var r0 CgroupNotifier
  38. if rf, ok := ret.Get(0).(func(string, string, int64) CgroupNotifier); ok {
  39. r0 = rf(a0, a1, a2)
  40. } else {
  41. if ret.Get(0) != nil {
  42. r0 = ret.Get(0).(CgroupNotifier)
  43. }
  44. }
  45. var r1 error
  46. if rf, ok := ret.Get(1).(func(string, string, int64) error); ok {
  47. r1 = rf(a0, a1, a2)
  48. } else {
  49. r1 = ret.Error(1)
  50. }
  51. return r0, r1
  52. }
  53. // MockThresholdNotifier is a mock implementation of the ThresholdNotifier interface
  54. type MockThresholdNotifier struct {
  55. mock.Mock
  56. }
  57. // Start implements the ThresholdNotifier interface
  58. func (m *MockThresholdNotifier) Start() {
  59. m.Called()
  60. }
  61. // UpdateThreshold implements the ThresholdNotifier interface
  62. func (m *MockThresholdNotifier) UpdateThreshold(a0 *statsapi.Summary) error {
  63. ret := m.Called(a0)
  64. var r0 error
  65. if rf, ok := ret.Get(0).(func(*statsapi.Summary) error); ok {
  66. r0 = rf(a0)
  67. } else {
  68. r0 = ret.Error(0)
  69. }
  70. return r0
  71. }
  72. // Description implements the ThresholdNotifier interface
  73. func (m *MockThresholdNotifier) Description() string {
  74. ret := m.Called()
  75. var r0 string
  76. if rf, ok := ret.Get(0).(func() string); ok {
  77. r0 = rf()
  78. } else {
  79. r0 = ret.String(0)
  80. }
  81. return r0
  82. }