From e919371fd9bbd1c60f39e94c6717c6d1daf0c9eb Mon Sep 17 00:00:00 2001 From: Charles Treatman Date: Thu, 31 Aug 2023 10:50:43 -0500 Subject: [PATCH] test: return non-nil error when device does not become active --- test/helper/helper.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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 {