8
8
"time"
9
9
10
10
"github.com/bmc-toolbox/bmclib/v2/constants"
11
- "github.com/bmc-toolbox/bmclib/v2/errors"
12
11
bmclibErrs "github.com/bmc-toolbox/bmclib/v2/errors"
13
12
"github.com/bmc-toolbox/common"
14
13
"github.com/stretchr/testify/assert"
@@ -41,7 +40,7 @@ func TestFirmwareInstall(t *testing.T) {
41
40
providersAttempted int
42
41
}{
43
42
{"success with metadata" , common .SlugBIOS , string (constants .OnReset ), false , nil , "1234" , nil , 5 * time .Second , "foo" , 1 },
44
- {"failure with metadata" , common .SlugBIOS , string (constants .OnReset ), false , nil , "1234" , errors .ErrNon200Response , 5 * time .Second , "foo" , 1 },
43
+ {"failure with metadata" , common .SlugBIOS , string (constants .OnReset ), false , nil , "1234" , bmclibErrs .ErrNon200Response , 5 * time .Second , "foo" , 1 },
45
44
{"failure with context timeout" , common .SlugBIOS , string (constants .OnReset ), false , nil , "1234" , context .DeadlineExceeded , 1 * time .Nanosecond , "foo" , 1 },
46
45
}
47
46
@@ -136,7 +135,7 @@ func TestFirmwareInstallStatus(t *testing.T) {
136
135
providersAttempted int
137
136
}{
138
137
{"success with metadata" , common .SlugBIOS , "1.1" , "1234" , constants .FirmwareInstallComplete , nil , 5 * time .Second , "foo" , 1 },
139
- {"failure with metadata" , common .SlugBIOS , "1.1" , "1234" , constants .FirmwareInstallFailed , errors .ErrNon200Response , 5 * time .Second , "foo" , 1 },
138
+ {"failure with metadata" , common .SlugBIOS , "1.1" , "1234" , constants .FirmwareInstallFailed , bmclibErrs .ErrNon200Response , 5 * time .Second , "foo" , 1 },
140
139
{"failure with context timeout" , common .SlugBIOS , "1.1" , "1234" , "" , context .DeadlineExceeded , 1 * time .Nanosecond , "foo" , 1 },
141
140
}
142
141
@@ -230,7 +229,7 @@ func TestFirmwareInstallUploaded(t *testing.T) {
230
229
providersAttempted int
231
230
}{
232
231
{"success with metadata" , common .SlugBIOS , "1234" , "5678" , nil , 5 * time .Second , "foo" , 1 },
233
- {"failure with metadata" , common .SlugBIOS , "1234" , "" , errors .ErrNon200Response , 5 * time .Second , "foo" , 1 },
232
+ {"failure with metadata" , common .SlugBIOS , "1234" , "" , bmclibErrs .ErrNon200Response , 5 * time .Second , "foo" , 1 },
234
233
{"failure with context timeout" , common .SlugBIOS , "1234" , "" , context .DeadlineExceeded , 1 * time .Nanosecond , "foo" , 1 },
235
234
}
236
235
@@ -325,7 +324,7 @@ func TestFirmwareUpload(t *testing.T) {
325
324
providersAttempted int
326
325
}{
327
326
{"success with metadata" , common .SlugBIOS , nil , "1234" , nil , 5 * time .Second , "foo" , 1 },
328
- {"failure with metadata" , common .SlugBIOS , nil , "1234" , errors .ErrNon200Response , 5 * time .Second , "foo" , 1 },
327
+ {"failure with metadata" , common .SlugBIOS , nil , "1234" , bmclibErrs .ErrNon200Response , 5 * time .Second , "foo" , 1 },
329
328
{"failure with context timeout" , common .SlugBIOS , nil , "1234" , context .DeadlineExceeded , 1 * time .Nanosecond , "foo" , 1 },
330
329
}
331
330
@@ -430,7 +429,7 @@ func TestFirmwareInstallSteps(t *testing.T) {
430
429
providersAttempted int
431
430
}{
432
431
{"success with metadata" , common .SlugBIOS , []constants.FirmwareInstallStep {constants .FirmwareInstallStepUpload , constants .FirmwareInstallStepInstallStatus }, nil , 5 * time .Second , "foo" , 1 },
433
- {"failure with metadata" , common .SlugBIOS , nil , errors .ErrNon200Response , 5 * time .Second , "foo" , 1 },
432
+ {"failure with metadata" , common .SlugBIOS , nil , bmclibErrs .ErrNon200Response , 5 * time .Second , "foo" , 1 },
434
433
{"failure with context timeout" , common .SlugBIOS , nil , context .DeadlineExceeded , 1 * time .Nanosecond , "foo" , 1 },
435
434
}
436
435
@@ -459,12 +458,12 @@ func TestFirmwareInstallSteps(t *testing.T) {
459
458
}
460
459
461
460
type firmwareTaskStatusTester struct {
462
- returnState string
461
+ returnState constants. TaskState
463
462
returnStatus string
464
463
returnError error
465
464
}
466
465
467
- func (f * firmwareTaskStatusTester ) FirmwareTaskStatus (ctx context.Context , kind constants.FirmwareInstallStep , component , taskID , installVersion string ) (state string , status string , err error ) {
466
+ func (f * firmwareTaskStatusTester ) FirmwareTaskStatus (ctx context.Context , kind constants.FirmwareInstallStep , component , taskID , installVersion string ) (state constants. TaskState , status string , err error ) {
468
467
return f .returnState , f .returnStatus , f .returnError
469
468
}
470
469
@@ -479,15 +478,15 @@ func TestFirmwareTaskStatus(t *testing.T) {
479
478
component string
480
479
taskID string
481
480
installVersion string
482
- returnState string
481
+ returnState constants. TaskState
483
482
returnStatus string
484
483
returnError error
485
484
ctxTimeout time.Duration
486
485
providerName string
487
486
providersAttempted int
488
487
}{
489
488
{"success with metadata" , constants .FirmwareInstallStepUpload , common .SlugBIOS , "1234" , "1.0" , constants .FirmwareInstallComplete , "Upload completed" , nil , 5 * time .Second , "foo" , 1 },
490
- {"failure with metadata" , constants .FirmwareInstallStepUpload , common .SlugBIOS , "1234" , "1.0" , constants .FirmwareInstallFailed , "Upload failed" , errors .ErrNon200Response , 5 * time .Second , "foo" , 1 },
489
+ {"failure with metadata" , constants .FirmwareInstallStepUpload , common .SlugBIOS , "1234" , "1.0" , constants .FirmwareInstallFailed , "Upload failed" , bmclibErrs .ErrNon200Response , 5 * time .Second , "foo" , 1 },
491
490
{"failure with context timeout" , constants .FirmwareInstallStepUpload , common .SlugBIOS , "1234" , "1.0" , "" , "" , context .DeadlineExceeded , 1 * time .Nanosecond , "foo" , 1 },
492
491
}
493
492
@@ -523,15 +522,15 @@ func TestFirmwareTaskStatusFromInterfaces(t *testing.T) {
523
522
component string
524
523
taskID string
525
524
installVersion string
526
- returnState string
525
+ returnState constants. TaskState
527
526
returnStatus string
528
527
returnError error
529
528
ctxTimeout time.Duration
530
529
providerName string
531
530
providersAttempted int
532
531
}{
533
- {"success with metadata" , constants .FirmwareInstallStepUpload , common .SlugBIOS , "1234" , "1.0" , constants .FirmwareInstallComplete , "uploading" , nil , 5 * time .Second , "foo" , 1 },
534
- {"failure with metadata" , constants .FirmwareInstallStepUpload , common .SlugBIOS , "1234" , "1.0" , constants .FirmwareInstallFailed , "failed" , errors .ErrNon200Response , 5 * time .Second , "foo" , 1 },
532
+ {"success with metadata" , constants .FirmwareInstallStepUpload , common .SlugBIOS , "1234" , "1.0" , constants .Complete , "uploading" , nil , 5 * time .Second , "foo" , 1 },
533
+ {"failure with metadata" , constants .FirmwareInstallStepUpload , common .SlugBIOS , "1234" , "1.0" , constants .Failed , "failed" , bmclibErrs .ErrNon200Response , 5 * time .Second , "foo" , 1 },
535
534
{"failure with context timeout" , constants .FirmwareInstallStepUpload , common .SlugBIOS , "1234" , "1.0" , "" , "" , context .DeadlineExceeded , 1 * time .Nanosecond , "foo" , 1 },
536
535
}
537
536
0 commit comments