mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-21 09:34:40 +00:00
Fix unit tests that expected the old FakeClient semantics
This commit is contained in:
parent
17ab25b121
commit
cd980ee076
@ -31,6 +31,8 @@ import (
|
||||
"k8s.io/client-go/kubernetes/fake"
|
||||
)
|
||||
|
||||
var noEndpoints = &corev1.Endpoints{}
|
||||
|
||||
func TestEndpointsAdapterGet(t *testing.T) {
|
||||
endpoints1, epSlice1 := generateEndpointsAndSlice("foo", "testing", []int{80, 443}, []string{"10.1.2.3", "10.1.2.4"})
|
||||
|
||||
@ -57,21 +59,21 @@ func TestEndpointsAdapterGet(t *testing.T) {
|
||||
},
|
||||
"endpointslice exists, endpoints does not": {
|
||||
expectedError: errors.NewNotFound(schema.GroupResource{Group: "", Resource: "endpoints"}, "foo"),
|
||||
expectedEndpoints: nil,
|
||||
expectedEndpoints: noEndpoints,
|
||||
initialState: []runtime.Object{epSlice1},
|
||||
namespaceParam: "testing",
|
||||
nameParam: "foo",
|
||||
},
|
||||
"wrong-namespace": {
|
||||
expectedError: errors.NewNotFound(schema.GroupResource{Group: "", Resource: "endpoints"}, "foo"),
|
||||
expectedEndpoints: nil,
|
||||
expectedEndpoints: noEndpoints,
|
||||
initialState: []runtime.Object{endpoints1, epSlice1},
|
||||
namespaceParam: "foo",
|
||||
nameParam: "foo",
|
||||
},
|
||||
"wrong-name": {
|
||||
expectedError: errors.NewNotFound(schema.GroupResource{Group: "", Resource: "endpoints"}, "bar"),
|
||||
expectedEndpoints: nil,
|
||||
expectedEndpoints: noEndpoints,
|
||||
initialState: []runtime.Object{endpoints1, epSlice1},
|
||||
namespaceParam: "testing",
|
||||
nameParam: "bar",
|
||||
@ -144,7 +146,7 @@ func TestEndpointsAdapterCreate(t *testing.T) {
|
||||
},
|
||||
"existing-endpoints": {
|
||||
expectedError: errors.NewAlreadyExists(schema.GroupResource{Group: "", Resource: "endpoints"}, "foo"),
|
||||
expectedResult: nil,
|
||||
expectedResult: noEndpoints,
|
||||
initialState: []runtime.Object{endpoints1, epSlice1},
|
||||
namespaceParam: endpoints1.Namespace,
|
||||
endpointsParam: endpoints1,
|
||||
@ -269,7 +271,7 @@ func TestEndpointsAdapterUpdate(t *testing.T) {
|
||||
},
|
||||
"wrong-endpoints": {
|
||||
expectedError: errors.NewNotFound(schema.GroupResource{Group: "", Resource: "endpoints"}, "bar"),
|
||||
expectedResult: nil,
|
||||
expectedResult: noEndpoints,
|
||||
expectUpdate: []runtime.Object{endpoints3},
|
||||
initialState: []runtime.Object{endpoints1, epSlice1},
|
||||
namespaceParam: "testing",
|
||||
@ -277,7 +279,7 @@ func TestEndpointsAdapterUpdate(t *testing.T) {
|
||||
},
|
||||
"missing-endpoints": {
|
||||
expectedError: errors.NewNotFound(schema.GroupResource{Group: "", Resource: "endpoints"}, "bar"),
|
||||
expectedResult: nil,
|
||||
expectedResult: noEndpoints,
|
||||
initialState: []runtime.Object{endpoints1, epSlice1},
|
||||
namespaceParam: "testing",
|
||||
endpointsParam: endpoints3,
|
||||
|
@ -83,6 +83,7 @@ func markVolumeAttached(t *testing.T, client clientset.Interface, watch *watch.R
|
||||
for i := 0; i < 100; i++ {
|
||||
attach, err = client.StorageV1().VolumeAttachments().Get(context.TODO(), attachID, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
attach = nil
|
||||
if apierrors.IsNotFound(err) {
|
||||
<-ticker.C
|
||||
continue
|
||||
|
@ -64,6 +64,7 @@ func Test_NodesDeleted(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedNode: &v1.Node{},
|
||||
expectedDeleted: true,
|
||||
fakeCloud: &fakecloud.Cloud{
|
||||
ExistsByProviderID: false,
|
||||
@ -178,6 +179,7 @@ func Test_NodesDeleted(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedNode: &v1.Node{},
|
||||
expectedDeleted: true,
|
||||
fakeCloud: &fakecloud.Cloud{
|
||||
ExistsByProviderID: false,
|
||||
@ -289,6 +291,7 @@ func Test_NodesDeleted(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedNode: &v1.Node{},
|
||||
expectedDeleted: true,
|
||||
fakeCloud: &fakecloud.Cloud{
|
||||
EnableInstancesV2: true,
|
||||
@ -406,6 +409,7 @@ func Test_NodesDeleted(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedNode: &v1.Node{},
|
||||
expectedDeleted: true,
|
||||
fakeCloud: &fakecloud.Cloud{
|
||||
EnableInstancesV2: true,
|
||||
@ -674,6 +678,7 @@ func Test_NodesShutdown(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedNode: &v1.Node{},
|
||||
expectedDeleted: true,
|
||||
fakeCloud: &fakecloud.Cloud{
|
||||
ErrShutdownByProviderID: nil,
|
||||
@ -751,6 +756,7 @@ func Test_NodesShutdown(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedNode: &v1.Node{},
|
||||
expectedDeleted: true,
|
||||
fakeCloud: &fakecloud.Cloud{
|
||||
ErrShutdownByProviderID: nil,
|
||||
@ -777,6 +783,7 @@ func Test_NodesShutdown(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedNode: &v1.Node{},
|
||||
expectedDeleted: true,
|
||||
fakeCloud: &fakecloud.Cloud{
|
||||
NodeShutdown: false,
|
||||
@ -801,6 +808,7 @@ func Test_NodesShutdown(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedNode: &v1.Node{},
|
||||
expectedDeleted: true,
|
||||
fakeCloud: &fakecloud.Cloud{
|
||||
NodeShutdown: false,
|
||||
@ -865,6 +873,7 @@ func Test_NodesShutdown(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedNode: &v1.Node{},
|
||||
expectedDeleted: true,
|
||||
fakeCloud: &fakecloud.Cloud{
|
||||
NodeShutdown: true,
|
||||
|
Loading…
Reference in New Issue
Block a user