Skip to content

Commit

Permalink
Update tests for plan status command
Browse files Browse the repository at this point in the history
Include timestamps in output, and define more than one plan.

Signed-off-by: Nick Jones <nick@dischord.org>
  • Loading branch information
yankcrime committed Mar 3, 2020
1 parent e287881 commit a1cc0e2
Showing 1 changed file with 29 additions and 6 deletions.
35 changes: 29 additions & 6 deletions pkg/kudoctl/cmd/plan/plan_status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package plan
import (
"bytes"
"testing"
"time"

"github.com/stretchr/testify/assert"
v1 "k8s.io/api/core/v1"
Expand All @@ -13,6 +14,10 @@ import (
"github.com/kudobuilder/kudo/pkg/kudoctl/util/kudo"
)

var (
testTime = time.Date(2019, 10, 17, 1, 1, 1, 1, time.UTC)
)

func TestStatus(t *testing.T) {
ov := &v1beta1.OperatorVersion{
TypeMeta: metav1.TypeMeta{
Expand All @@ -24,7 +29,21 @@ func TestStatus(t *testing.T) {
},
Spec: v1beta1.OperatorVersionSpec{
Version: "1.0",
Plans: map[string]v1beta1.Plan{"deploy": {}},
Plans: map[string]v1beta1.Plan{
"validate": {
Phases: []v1beta1.Phase{
v1beta1.Phase{
Name: "validate",
Steps: []v1beta1.Step{
v1beta1.Step{
Name: "validate",
},
},
},
},
},
"deploy": {},
},
}}
instance := &v1beta1.Instance{
TypeMeta: metav1.TypeMeta{
Expand All @@ -45,8 +64,9 @@ func TestStatus(t *testing.T) {
fatalErrInstance.Status = v1beta1.InstanceStatus{
PlanStatus: map[string]v1beta1.PlanStatus{
"deploy": {
Name: "deploy",
Status: v1beta1.ExecutionFatalError,
Name: "deploy",
Status: v1beta1.ExecutionFatalError,
LastUpdatedTimestamp: &metav1.Time{Time: testTime},
Phases: []v1beta1.PhaseStatus{
{
Name: "deploy",
Expand Down Expand Up @@ -78,9 +98,12 @@ func TestStatus(t *testing.T) {
{"fatal error in a plan", fatalErrInstance, ov, "test", "", `Plan(s) for "test" in namespace "default":
.
└── test (Operator-Version: "test-1.0" Active-Plan: "deploy")
└── Plan deploy ( strategy) [FATAL_ERROR]
└── Phase deploy ( strategy) [FATAL_ERROR]
└── Step deploy [FATAL_ERROR] (error detail)
├── Plan deploy ( strategy) [FATAL_ERROR], last updated 2019-10-17 01:01:01
│   └── Phase deploy ( strategy) [FATAL_ERROR]
│   └── Step deploy [FATAL_ERROR] (error detail)
└── Plan validate ( strategy) [NOT ACTIVE]
└── Phase validate ( strategy) [NOT ACTIVE]
└── Step validate [NOT ACTIVE]
`},
}
Expand Down

0 comments on commit a1cc0e2

Please sign in to comment.