Better handle unknown state.

Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
Lantao Liu
2019-12-05 14:51:02 -08:00
parent 0881caa9bd
commit facbaa0e79
5 changed files with 24 additions and 1 deletions

View File

@@ -36,6 +36,12 @@ func TestContainerState(t *testing.T) {
state runtime.ContainerState
}{
"unknown state": {
status: Status{
Unknown: true,
},
state: runtime.ContainerState_CONTAINER_UNKNOWN,
},
"unknown state because there is no timestamp set": {
status: Status{},
state: runtime.ContainerState_CONTAINER_UNKNOWN,
},
@@ -76,6 +82,7 @@ func TestStatusEncodeDecode(t *testing.T) {
Message: "test-message",
Removing: true,
Starting: true,
Unknown: true,
}
assert := assertlib.New(t)
data, err := s.encode()
@@ -84,6 +91,7 @@ func TestStatusEncodeDecode(t *testing.T) {
assert.NoError(newS.decode(data))
s.Removing = false // Removing should not be encoded.
s.Starting = false // Starting should not be encoded.
s.Unknown = false // Unknown should not be encoded.
assert.Equal(s, newS)
unsupported, err := json.Marshal(&versionedStatus{