mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 06:27:05 +00:00
Merge pull request #6468 from derekwaynecarr/improve_test
Improve test case to ensure finalize does desired behavior
This commit is contained in:
commit
55fe466aca
@ -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
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user