Improve test case to ensure finalize does desired behavior

This commit is contained in:
derekwaynecarr 2015-04-06 13:13:06 -04:00
parent bfde7e0735
commit b1dca3232f
3 changed files with 10 additions and 1 deletions

View File

@ -47,6 +47,7 @@ type Fake struct {
ResourceQuotaStatus api.ResourceQuota
ResourceQuotasList api.ResourceQuotaList
NamespacesList api.NamespaceList
Namespace api.Namespace
SecretList api.SecretList
Secret api.Secret
Err error

View File

@ -61,7 +61,8 @@ func (c *FakeNamespaces) Watch(label labels.Selector, field fields.Selector, res
func (c *FakeNamespaces) Finalize(namespace *api.Namespace) (*api.Namespace, error) {
c.Fake.Actions = append(c.Fake.Actions, FakeAction{Action: "finalize-namespace", Value: namespace.Name})
return &api.Namespace{}, nil
c.Fake.Namespace = *namespace
return namespace, nil
}
func (c *FakeNamespaces) Status(namespace *api.Namespace) (*api.Namespace, error) {

View File

@ -58,6 +58,13 @@ func TestFinalize(t *testing.T) {
if mockClient.Actions[0].Action != "finalize-namespace" {
t.Errorf("Expected finalize-namespace action %v", mockClient.Actions[0].Action)
}
finalizers := mockClient.Namespace.Spec.Finalizers
if len(finalizers) != 1 {
t.Errorf("There should be a single finalizer remaining")
}
if "other" != string(finalizers[0]) {
t.Errorf("Unexpected finalizer value, %v", finalizers[0])
}
}
func TestSyncNamespaceThatIsTerminating(t *testing.T) {