diff --git a/test/helper/helper.go b/test/helper/helper.go index 723760e4..eb1007ef 100644 --- a/test/helper/helper.go +++ b/test/helper/helper.go @@ -52,14 +52,12 @@ func CreateTestDevice(projectId, name string) (string, error) { } func IsDeviceStateActive(deviceId string) (bool, error) { - var err error - var resp *openapiclient.Device TestApiClient := TestClient() predefinedTime := 500 * time.Second // Adjust this as needed retryInterval := 10 * time.Second // Adjust this as needed startTime := time.Now() for time.Since(startTime) < predefinedTime { - resp, _, err = TestApiClient.DevicesApi.FindDeviceById(context.Background(), deviceId).Execute() + resp, _, err := TestApiClient.DevicesApi.FindDeviceById(context.Background(), deviceId).Execute() if err != nil { fmt.Fprintf(os.Stderr, "Error when calling `DevicesApi.FindDeviceById``: %v\n", err) return false, err @@ -71,7 +69,7 @@ func IsDeviceStateActive(deviceId string) (bool, error) { // Sleep for the specified interval time.Sleep(retryInterval) } - return false, err + return false, fmt.Errorf("timed out waiting for device %v to become active", deviceId) } func StopTestDevice(deviceId string) error {