Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
| ... | ... |
@@ -102,15 +102,6 @@ func (s *State) String() string {
|
| 102 | 102 |
return fmt.Sprintf("Exited (%d) %s ago", s.ExitCodeValue, units.HumanDuration(time.Now().UTC().Sub(s.FinishedAt)))
|
| 103 | 103 |
} |
| 104 | 104 |
|
| 105 |
-// HealthString returns a single string to describe health status. |
|
| 106 |
-func (s *State) HealthString() string {
|
|
| 107 |
- if s.Health == nil {
|
|
| 108 |
- return types.NoHealthcheck |
|
| 109 |
- } |
|
| 110 |
- |
|
| 111 |
- return s.Health.String() |
|
| 112 |
-} |
|
| 113 |
- |
|
| 114 | 105 |
// IsValidHealthString checks if the provided string is a valid container health status or not. |
| 115 | 106 |
func IsValidHealthString(s string) bool {
|
| 116 | 107 |
return s == types.Starting || |
| ... | ... |
@@ -6,6 +6,7 @@ import ( |
| 6 | 6 |
"path/filepath" |
| 7 | 7 |
"testing" |
| 8 | 8 |
|
| 9 |
+ "github.com/docker/docker/api/types" |
|
| 9 | 10 |
containertypes "github.com/docker/docker/api/types/container" |
| 10 | 11 |
"github.com/pborman/uuid" |
| 11 | 12 |
"github.com/stretchr/testify/assert" |
| ... | ... |
@@ -159,3 +160,26 @@ func TestNames(t *testing.T) {
|
| 159 | 159 |
view = db.Snapshot() |
| 160 | 160 |
assert.Equal(t, map[string][]string{"containerid4": {"name1", "name2"}}, view.GetAllNames())
|
| 161 | 161 |
} |
| 162 |
+ |
|
| 163 |
+// Test case for GitHub issue 35920 |
|
| 164 |
+func TestViewWithHealthCheck(t *testing.T) {
|
|
| 165 |
+ var ( |
|
| 166 |
+ db, _ = NewViewDB() |
|
| 167 |
+ one = newContainer(t) |
|
| 168 |
+ ) |
|
| 169 |
+ one.Health = &Health{
|
|
| 170 |
+ Health: types.Health{
|
|
| 171 |
+ Status: "starting", |
|
| 172 |
+ }, |
|
| 173 |
+ } |
|
| 174 |
+ if err := one.CheckpointTo(db); err != nil {
|
|
| 175 |
+ t.Fatal(err) |
|
| 176 |
+ } |
|
| 177 |
+ s, err := db.Snapshot().Get(one.ID) |
|
| 178 |
+ if err != nil {
|
|
| 179 |
+ t.Fatal(err) |
|
| 180 |
+ } |
|
| 181 |
+ if s == nil || s.Health != "starting" {
|
|
| 182 |
+ t.Fatalf("expected Health=starting. Got: %+v", s)
|
|
| 183 |
+ } |
|
| 184 |
+} |