mock.go 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package clustercache
  2. // MockClusterCache is a configurable implementation of ClusterCache for use in tests.
  3. // Each field corresponds to the slice returned by the matching GetAll* method.
  4. // Any field left nil causes its method to return nil.
  5. type MockClusterCache struct {
  6. Nodes []*Node
  7. Pods []*Pod
  8. Namespaces []*Namespace
  9. Services []*Service
  10. DaemonSets []*DaemonSet
  11. Deployments []*Deployment
  12. StatefulSets []*StatefulSet
  13. ReplicaSets []*ReplicaSet
  14. PersistentVolumes []*PersistentVolume
  15. PersistentVolumeClaims []*PersistentVolumeClaim
  16. StorageClasses []*StorageClass
  17. Jobs []*Job
  18. CronJobs []*CronJob
  19. PodDisruptionBudgets []*PodDisruptionBudget
  20. ReplicationControllers []*ReplicationController
  21. ResourceQuotas []*ResourceQuota
  22. }
  23. func (m *MockClusterCache) Run() {}
  24. func (m *MockClusterCache) Stop() {}
  25. func (m *MockClusterCache) GetAllNodes() []*Node { return m.Nodes }
  26. func (m *MockClusterCache) GetAllPods() []*Pod { return m.Pods }
  27. func (m *MockClusterCache) GetAllNamespaces() []*Namespace { return m.Namespaces }
  28. func (m *MockClusterCache) GetAllServices() []*Service { return m.Services }
  29. func (m *MockClusterCache) GetAllDaemonSets() []*DaemonSet { return m.DaemonSets }
  30. func (m *MockClusterCache) GetAllDeployments() []*Deployment { return m.Deployments }
  31. func (m *MockClusterCache) GetAllStatefulSets() []*StatefulSet { return m.StatefulSets }
  32. func (m *MockClusterCache) GetAllReplicaSets() []*ReplicaSet { return m.ReplicaSets }
  33. func (m *MockClusterCache) GetAllPersistentVolumes() []*PersistentVolume { return m.PersistentVolumes }
  34. func (m *MockClusterCache) GetAllPersistentVolumeClaims() []*PersistentVolumeClaim {
  35. return m.PersistentVolumeClaims
  36. }
  37. func (m *MockClusterCache) GetAllStorageClasses() []*StorageClass { return m.StorageClasses }
  38. func (m *MockClusterCache) GetAllJobs() []*Job { return m.Jobs }
  39. func (m *MockClusterCache) GetAllCronJobs() []*CronJob { return m.CronJobs }
  40. func (m *MockClusterCache) GetAllPodDisruptionBudgets() []*PodDisruptionBudget {
  41. return m.PodDisruptionBudgets
  42. }
  43. func (m *MockClusterCache) GetAllReplicationControllers() []*ReplicationController {
  44. return m.ReplicationControllers
  45. }
  46. func (m *MockClusterCache) GetAllResourceQuotas() []*ResourceQuota { return m.ResourceQuotas }