mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-14 13:45:06 +00:00
Updated stripFieldsTest to be run with update instead of apply
This commit is contained in:
@@ -22,9 +22,12 @@ import (
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"time"
|
||||
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/apimachinery/pkg/api/meta"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
@@ -76,37 +79,36 @@ func TestApplyStripsFields(t *testing.T) {
|
||||
|
||||
obj := &corev1.Pod{}
|
||||
|
||||
newObj, err := f.Apply(obj, []byte(`{
|
||||
"apiVersion": "apps/v1",
|
||||
"kind": "Deployment",
|
||||
"metadata": {
|
||||
"name": "b",
|
||||
"namespace": "b",
|
||||
"creationTimestamp": "2016-05-19T09:59:00Z",
|
||||
"selfLink": "b",
|
||||
"uid": "b",
|
||||
"clusterName": "b",
|
||||
"generation": 0,
|
||||
"managedFields": [{
|
||||
"manager": "apply",
|
||||
"operation": "Apply",
|
||||
"apiVersion": "apps/v1",
|
||||
"fields": {
|
||||
"f:metadata": {
|
||||
"f:labels": {
|
||||
"f:test-label": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}],
|
||||
"resourceVersion": "b"
|
||||
}
|
||||
}`), "fieldmanager_test", false)
|
||||
newObj := &corev1.Pod{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
APIVersion: "apps/v1",
|
||||
Kind: "Deployment",
|
||||
},
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "b",
|
||||
Namespace: "b",
|
||||
CreationTimestamp: metav1.NewTime(time.Now()),
|
||||
SelfLink: "b",
|
||||
UID: "b",
|
||||
ClusterName: "b",
|
||||
Generation: 0,
|
||||
ManagedFields: []metav1.ManagedFieldsEntry{
|
||||
{
|
||||
Manager: "update",
|
||||
Operation: metav1.ManagedFieldsOperationApply,
|
||||
APIVersion: "apps/v1",
|
||||
},
|
||||
},
|
||||
ResourceVersion: "b",
|
||||
},
|
||||
}
|
||||
|
||||
updatedObj, err := f.Update(obj, newObj, "fieldmanager_test")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to apply object: %v", err)
|
||||
}
|
||||
|
||||
accessor, err := meta.Accessor(newObj)
|
||||
accessor, err := meta.Accessor(updatedObj)
|
||||
if err != nil {
|
||||
t.Fatalf("couldn't get accessor: %v", err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user