Skip to content

Commit

Permalink
providers/asrr: use constants for the model names
Browse files Browse the repository at this point in the history
  • Loading branch information
joelrebel committed Dec 5, 2023
1 parent 905a954 commit 8340289
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
10 changes: 7 additions & 3 deletions providers/asrockrack/asrockrack.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ const (
ProviderName = "asrockrack"
// ProviderProtocol for the provider implementation
ProviderProtocol = "vendorapi"

E3C256D4ID_NL = "E3C256D4ID-NL"
E3C246D4ID_NL = "E3C246D4ID-NL"
E3C246D4I_NL = "E3C246D4I-NL"
)

var (
Expand Down Expand Up @@ -119,9 +123,9 @@ func (a *ASRockRack) Open(ctx context.Context) (err error) {

func (a *ASRockRack) supported(ctx context.Context) error {
supported := []string{
"E3C256D4ID-NL",
"E3C246D4ID-NL",
"E3C246D4I-NL",
E3C256D4ID_NL,
E3C246D4ID_NL,
E3C246D4I_NL,
}

if a.deviceModel == "" {
Expand Down
2 changes: 1 addition & 1 deletion providers/asrockrack/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func (a *ASRockRack) setFlashMode(ctx context.Context) error {
pConfig := &preserveConfig{}
// preserve config is needed by e3c256d4i
switch device.Model {
case "E3C256D4ID-NL":
case E3C256D4ID_NL:

Check warning on line 195 in providers/asrockrack/helpers.go

View check run for this annotation

Codecov / codecov/patch

providers/asrockrack/helpers.go#L195

Added line #L195 was not covered by tests
pConfig = &preserveConfig{PreserveConfig: 1}
}

Expand Down
2 changes: 1 addition & 1 deletion providers/asrockrack/inventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func (a *ASRockRack) systemAttributes(ctx context.Context, device *common.Device
device.Metadata["node_id"] = fwInfo.NodeID

switch device.Model {
case "E3C246D4ID-NL", "E3C246D4I-NL":
case E3C246D4ID_NL, E3C246D4I_NL:
return a.componentAttributesE3C246(ctx, fwInfo, device)
default:
return nil

Check warning on line 149 in providers/asrockrack/inventory.go

View check run for this annotation

Codecov / codecov/patch

providers/asrockrack/inventory.go#L148-L149

Added lines #L148 - L149 were not covered by tests
Expand Down
4 changes: 2 additions & 2 deletions providers/asrockrack/inventory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ func TestGetInventory(t *testing.T) {
t.Fatal(err)
}

aClient.deviceModel = "E3C246D4I-NL"
aClient.deviceModel = E3C246D4I_NL
assert.NotNil(t, device)
assert.Equal(t, "ASRockRack", device.Vendor)
assert.Equal(t, "E3C246D4I-NL", device.Model)
assert.Equal(t, E3C246D4I_NL, device.Model)

assert.Equal(t, "L2.07B", device.BIOS.Firmware.Installed)
assert.Equal(t, "0.01.00", device.BMC.Firmware.Installed)
Expand Down

0 comments on commit 8340289

Please sign in to comment.