@@ -1767,7 +1767,7 @@ U5wwSivyi7vmegHKmblOzNVKA5qPO8zWzqBC
17671767
17681768 By ("deleting the Node" )
17691769 nodeName := node .Name
1770- err = cl .Delete (context . TODO () , node )
1770+ err = cl .Delete (ctx , node )
17711771 Expect (err ).NotTo (HaveOccurred ())
17721772 Expect (node .ObjectMeta .DeletionTimestamp ).NotTo (BeNil ())
17731773
@@ -1940,7 +1940,48 @@ U5wwSivyi7vmegHKmblOzNVKA5qPO8zWzqBC
19401940 _ , err = clientset .AppsV1 ().Deployments (ns ).Get (ctx , dep2Name , metav1.GetOptions {})
19411941 Expect (err ).To (HaveOccurred ())
19421942 })
1943+
1944+ It ("should update the resource when deleting if it receives a response" , func () {
1945+ cl , err := client .New (cfg , client.Options {})
1946+ Expect (err ).NotTo (HaveOccurred ())
1947+ Expect (cl ).NotTo (BeNil ())
1948+
1949+ By ("initially creating a Node" )
1950+ node , err := clientset .CoreV1 ().Nodes ().Create (ctx , node , metav1.CreateOptions {})
1951+ Expect (err ).NotTo (HaveOccurred ())
1952+
1953+ By ("adding a finalizer we prevent the node from being deleted immediately" )
1954+ controllerutil .AddFinalizer (node , "example.com/test" )
1955+ node , err = clientset .CoreV1 ().Nodes ().Update (ctx , node , metav1.UpdateOptions {})
1956+ Expect (err ).NotTo (HaveOccurred ())
1957+
1958+ By ("deleting the Node" )
1959+ nodeName := node .Name
1960+ u := & unstructured.Unstructured {}
1961+ Expect (scheme .Convert (node , u , nil )).To (Succeed ())
1962+ u .SetGroupVersionKind (schema.GroupVersionKind {
1963+ Group : "" ,
1964+ Kind : "Node" ,
1965+ Version : "v1" ,
1966+ })
1967+ err = cl .Delete (ctx , u )
1968+ Expect (err ).NotTo (HaveOccurred ())
1969+
1970+ accessor , err := meta .Accessor (u )
1971+ Expect (err ).NotTo (HaveOccurred ())
1972+ Expect (accessor .GetDeletionTimestamp ()).NotTo (BeNil ())
1973+
1974+ By ("removing the finalizer" )
1975+ controllerutil .RemoveFinalizer (u , "example.com/test" )
1976+ err = cl .Delete (ctx , u )
1977+ Expect (err ).NotTo (HaveOccurred ())
1978+
1979+ By ("validating the Node no longer exists" )
1980+ _ , err = clientset .CoreV1 ().Nodes ().Get (ctx , nodeName , metav1.GetOptions {})
1981+ Expect (err ).NotTo (HaveOccurred ())
1982+ })
19431983 })
1984+
19441985 Context ("with metadata objects" , func () {
19451986 It ("should delete an existing object from a go struct" , func (ctx SpecContext ) {
19461987 cl , err := client .New (cfg , client.Options {})
0 commit comments