Clear pod cache on delete.

This commit is contained in:
Brendan Burns
2015-01-26 16:11:16 -08:00
parent c65f83f424
commit f124842505
4 changed files with 79 additions and 0 deletions

View File

@@ -125,6 +125,36 @@ func TestPodCacheGet(t *testing.T) {
}
}
func TestPodCacheDelete(t *testing.T) {
cache := NewPodCache(nil, nil, nil, nil)
expected := api.PodStatus{
Info: api.PodInfo{
"foo": api.ContainerStatus{},
},
}
cache.podStatus[objKey{api.NamespaceDefault, "foo"}] = expected
info, err := cache.GetPodStatus(api.NamespaceDefault, "foo")
if err != nil {
t.Errorf("Unexpected error: %+v", err)
}
if !reflect.DeepEqual(info, &expected) {
t.Errorf("Unexpected mismatch. Expected: %+v, Got: %+v", &expected, info)
}
cache.ClearPodStatus(api.NamespaceDefault, "foo")
_, err = cache.GetPodStatus(api.NamespaceDefault, "foo")
if err == nil {
t.Errorf("Unexpected non-error after deleting")
}
if err != client.ErrPodInfoNotAvailable {
t.Errorf("Unexpected error: %v, expecting: %v", err, client.ErrPodInfoNotAvailable)
}
}
func TestPodCacheGetMissing(t *testing.T) {
cache := NewPodCache(nil, nil, nil, nil)