Add tests for status cli

This commit is contained in:
Morten Torkildsen
2019-12-30 21:38:06 -08:00
parent 3577a7e174
commit f0d81c4fac
14 changed files with 1019 additions and 24 deletions

View File

@@ -4,6 +4,7 @@
package status
import (
"fmt"
"time"
"github.com/pkg/errors"
@@ -26,6 +27,11 @@ const (
UnknownStatus Status = "Unknown"
)
var (
Statuses = []Status{InProgressStatus, FailedStatus, CurrentStatus, TerminatingStatus, UnknownStatus}
ConditionTypes = []ConditionType{ConditionFailed, ConditionInProgress}
)
// ConditionType defines the set of condition types allowed inside a Condition struct.
type ConditionType string
@@ -42,6 +48,18 @@ func (s Status) String() string {
return string(s)
}
// StatusFromString turns a string into a Status. Will panic if the provided string is
// not a valid status.
func FromStringOrDie(text string) Status {
s := Status(text)
for _, r := range Statuses {
if s == r {
return s
}
}
panic(fmt.Errorf("string has invalid status: %s", s))
}
// Result contains the results of a call to compute the status of
// a resource.
type Result struct {