mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
update testDeleteWithResourceVersion
This commit is contained in:
parent
4ddc198c39
commit
fe3b9f486f
@ -228,8 +228,8 @@ func NewUIDPreconditions(uid string) *Preconditions {
|
|||||||
return &Preconditions{UID: &u}
|
return &Preconditions{UID: &u}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewPreconditionDeleteOptionsWithResourceVersion returns a DeleteOptions with a ResourceVersion precondition set.
|
// NewRVDeletionPrecondition returns a DeleteOptions with a ResourceVersion precondition set.
|
||||||
func NewPreconditionDeleteOptionsWithResourceVersion(rv string) *DeleteOptions {
|
func NewRVDeletionPrecondition(rv string) *DeleteOptions {
|
||||||
p := Preconditions{ResourceVersion: &rv}
|
p := Preconditions{ResourceVersion: &rv}
|
||||||
return &DeleteOptions{Preconditions: &p}
|
return &DeleteOptions{Preconditions: &p}
|
||||||
}
|
}
|
||||||
|
@ -921,13 +921,15 @@ func (t *Tester) testDeleteWithResourceVersion(obj runtime.Object, createFn Crea
|
|||||||
if err := createFn(ctx, foo); err != nil {
|
if err := createFn(ctx, foo); err != nil {
|
||||||
t.Errorf("unexpected error: %v", err)
|
t.Errorf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
opts.Preconditions = metav1.NewPreconditionDeleteOptionsWithResourceVersion("RV1111").Preconditions
|
opts.Preconditions = metav1.NewRVDeletionPrecondition("RV1111").Preconditions
|
||||||
obj, _, err := t.storage.(rest.GracefulDeleter).Delete(ctx, objectMeta.GetName(), &opts)
|
obj, wasDeleted, err := t.storage.(rest.GracefulDeleter).Delete(ctx, objectMeta.GetName(), &opts)
|
||||||
if err == nil || !errors.IsConflict(err) {
|
if err == nil || !errors.IsConflict(err) {
|
||||||
t.Errorf("unexpected error: %v", err)
|
t.Errorf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
|
if wasDeleted {
|
||||||
obj, _, err = t.storage.(rest.GracefulDeleter).Delete(ctx, objectMeta.GetName(), metav1.NewPreconditionDeleteOptionsWithResourceVersion("RV0000"))
|
t.Errorf("unexpected, object %s should not have been deleted immediately", objectMeta.GetName())
|
||||||
|
}
|
||||||
|
obj, _, err = t.storage.(rest.GracefulDeleter).Delete(ctx, objectMeta.GetName(), metav1.NewRVDeletionPrecondition("RV0000"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("unexpected error: %v", err)
|
t.Errorf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user