mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-06 18:11:44 +02:00
put mock methods to k8sutil to avoid cycling imports
This commit is contained in:
@@ -148,6 +148,7 @@ func (c *Cluster) setProcessName(procName string, args ...interface{}) {
|
||||
}
|
||||
}
|
||||
|
||||
// SetStatus of Postgres cluster
|
||||
func (c *Cluster) SetStatus(status string) {
|
||||
// TODO: eventually switch to updateStatus() for kubernetes 1.11 and above
|
||||
patch, err := json.Marshal(acidv1.PostgresStatus{PostgresClusterStatus: status})
|
||||
|
||||
@@ -30,7 +30,7 @@ var cl = New(
|
||||
},
|
||||
},
|
||||
},
|
||||
k8sutil.KubernetesClient{},
|
||||
k8sutil.NewMockKubernetesClient(),
|
||||
acidv1.Postgresql{},
|
||||
logger,
|
||||
)
|
||||
@@ -328,3 +328,31 @@ func TestShouldDeleteSecret(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetStatus(t *testing.T) {
|
||||
|
||||
tests := []struct {
|
||||
status acidv1.PostgresStatus
|
||||
outcome bool
|
||||
}{
|
||||
{
|
||||
status: acidv1.PostgresStatus{PostgresClusterStatus: acidv1.ClusterStatusCreating},
|
||||
outcome: cl.Status.Creating(),
|
||||
},
|
||||
{
|
||||
status: acidv1.PostgresStatus{PostgresClusterStatus: acidv1.ClusterStatusRunning},
|
||||
outcome: cl.Status.Running(),
|
||||
},
|
||||
{
|
||||
status: acidv1.PostgresStatus{PostgresClusterStatus: acidv1.ClusterStatusInvalid},
|
||||
outcome: !cl.Status.Success(),
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
cl.SetStatus(tt.status.PostgresClusterStatus)
|
||||
if tt.outcome {
|
||||
t.Errorf("Wrong status: %s", cl.Status.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user