From f0888b6017d33dc9427a6c2a6c854a9f83abdabb Mon Sep 17 00:00:00 2001 From: Felix Kunde Date: Thu, 18 Apr 2019 12:05:25 +0200 Subject: [PATCH] add test for setStatus --- pkg/cluster/cluster_test.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/pkg/cluster/cluster_test.go b/pkg/cluster/cluster_test.go index 5ff00c7b3..4f95a70cb 100644 --- a/pkg/cluster/cluster_test.go +++ b/pkg/cluster/cluster_test.go @@ -318,3 +318,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.ClusterStatusSyncFailed}, + outcome: !cl.Status.Success(), + }, + } + + for _, tt := range tests { + cl.setStatus(tt.status.PostgresClusterStatus) + if tt.outcome { + t.Errorf("Wrong status: %s", cl.Status.String()) + } + } +}