gce: fix test for non-existing instance in cloud

This commit fixes a GCE instance test for a scenario where instance does
not exist in the cloud. In the `gce_instances.go` we have a code that
handles such a scenario and strips off the error, i.e.

```
if providerID, err = cloudprovider.GetInstanceProviderID(ctx, g, types.NodeName(node.Name)); err != nil {
	if err == cloudprovider.InstanceNotFound {
		return false, nil
	}
	return false, err
}
```

but nevertheless the test was expecing a non-empty error string. This
issue got exposed when implementation of `GetInstanceProviderID` in the
`cloud-provider/cloud.go` changed to return `InstanceNotFound` as-is and
not as a custom string.

Signed-off-by: Mat Kowalski <mko@redhat.com>
This commit is contained in:
Mat Kowalski 2023-10-26 11:33:33 +02:00
parent 4a640ea384
commit 60a602f170
No known key found for this signature in database
GPG Key ID: 7E2A225088D24529

View File

@ -21,7 +21,6 @@ package gce
import (
"context"
"fmt"
"testing"
"github.com/stretchr/testify/assert"
@ -55,7 +54,7 @@ func TestInstanceExists(t *testing.T) {
name: "node not exist",
nodeName: "test-node-2",
exist: false,
expectedErr: fmt.Errorf("failed to get instance ID from cloud provider: instance not found"),
expectedErr: nil,
},
}