Skip to content

Commit

Permalink
unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rjbrache committed Oct 18, 2024
1 parent da7dcfb commit b7daaf4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion internal/entity/dto/v1/hardwareinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ type (
CIMComputerSystemPackage CIMComputerSystemPackage
CIMSystemPackage CIMSystemPackage
CIMChassis CIMChassis
CIMChip CIMChips
CIMChip CIMChips `json:"CIMChip" binding:"required"`
CIMCard CIMCard
CIMBIOSElement CIMBIOSElement
CIMProcessor CIMProcessor
Expand Down
12 changes: 7 additions & 5 deletions internal/usecase/devices/info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/open-amt-cloud-toolkit/console/internal/entity/dto/v1"
"github.com/open-amt-cloud-toolkit/console/internal/mocks"
devices "github.com/open-amt-cloud-toolkit/console/internal/usecase/devices"
"github.com/open-amt-cloud-toolkit/console/internal/usecase/devices/wsman"
"github.com/open-amt-cloud-toolkit/console/pkg/logger"
)

Expand Down Expand Up @@ -271,14 +272,15 @@ func TestGetHardwareInfo(t *testing.T) {
Return(man2)
man2.EXPECT().
GetHardwareInfo().
Return(gomock.Any(), nil)
Return(wsman.HWResults{}, nil)
},
repoMock: func(repo *mocks.MockDeviceManagementRepository) {
repo.EXPECT().
GetByID(context.Background(), device.GUID, "").
Return(device, nil)
},
res: gomock.Any(),
// res: dto.HardwareInfoResults{},
res: dto.HardwareInfoResults{CIMComputerSystemPackage:dto.CIMComputerSystemPackage{Response:"", Responses:""}, CIMSystemPackage:dto.CIMSystemPackage{Responses:[]dto.CIMSystemPackagingResponses(nil)}, CIMChassis:dto.CIMChassis{Response:dto.CIMChassisResponse{Version:"", SerialNumber:"", Model:"", Manufacturer:"", ElementName:"", CreationClassName:"", Tag:"", OperationalStatus:[]int(nil), PackageType:0, ChassisPackageType:0}, Responses:[]interface {}(nil)}, CIMChip:dto.CIMChips{Responses:[]dto.CIMChipGet{dto.CIMChipGet{CanBeFRUed:false, CreationClassName:"", ElementName:"", Manufacturer:"", OperationalStatus:[]int(nil), Tag:"", Version:""}}}, CIMCard:dto.CIMCard{Response:dto.CIMCardResponseGet{CanBeFRUed:false, CreationClassName:"", ElementName:"", Manufacturer:"", Model:"", OperationalStatus:[]int(nil), PackageType:0, SerialNumber:"", Tag:"", Version:""}, Responses:[]interface {}(nil)}, CIMBIOSElement:dto.CIMBIOSElement{Response:dto.CIMBIOSElementResponse{TargetOperatingSystem:0, SoftwareElementID:"", SoftwareElementState:0, Name:"", OperationalStatus:[]int(nil), ElementName:"", Version:"", Manufacturer:"", PrimaryBIOS:false, ReleaseDate:dto.Time{DateTime:""}}, Responses:[]interface {}(nil)}, CIMProcessor:dto.CIMProcessor{Responses:[]dto.CIMProcessorResponse{dto.CIMProcessorResponse{DeviceID:"", CreationClassName:"", SystemName:"", SystemCreationClassName:"", ElementName:"", OperationalStatus:[]int(nil), HealthState:0, EnabledState:0, RequestedState:0, Role:"", Family:0, OtherFamilyDescription:"", UpgradeMethod:0, MaxClockSpeed:0, CurrentClockSpeed:0, Stepping:"", CPUStatus:0, ExternalBusClockSpeed:0}}}, CIMPhysicalPackage:dto.CIMPhysicalPackage{Responses:[]dto.CIMPhysicalPackageResponses(nil)}, CIMPhysicalMemory:dto.CIMPhysicalMemory{Responses:[]dto.CIMPhysicalMemoryResponse(nil)}, CIMMediaAccessDevice:dto.CIMMediaAccessDevice{Pull:[]interface {}(nil), Get:struct { Capabilities []int; CreationClassName string; DeviceID string; ElementName string; EnabledDefault int; EnabledState int; MaxMediaSize int; OperationalStatus []int; RequestedState int; Security int; SystemCreationClassName string; SystemName string }{Capabilities:[]int(nil), CreationClassName:"", DeviceID:"", ElementName:"", EnabledDefault:0, EnabledState:0, MaxMediaSize:0, OperationalStatus:[]int(nil), RequestedState:0, Security:0, SystemCreationClassName:"", SystemName:""}}},

Check failure on line 283 in internal/usecase/devices/info_test.go

View workflow job for this annotation

GitHub Actions / runner / golangci-lint

[golangci] reported by reviewdog 🐶 File is not `gci`-ed with --skip-generated -s standard -s default (gci) Raw Output: internal/usecase/devices/info_test.go:283: File is not `gci`-ed with --skip-generated -s standard -s default (gci) res: dto.HardwareInfoResults{CIMComputerSystemPackage:dto.CIMComputerSystemPackage{Response:"", Responses:""}, CIMSystemPackage:dto.CIMSystemPackage{Responses:[]dto.CIMSystemPackagingResponses(nil)}, CIMChassis:dto.CIMChassis{Response:dto.CIMChassisResponse{Version:"", SerialNumber:"", Model:"", Manufacturer:"", ElementName:"", CreationClassName:"", Tag:"", OperationalStatus:[]int(nil), PackageType:0, ChassisPackageType:0}, Responses:[]interface {}(nil)}, CIMChip:dto.CIMChips{Responses:[]dto.CIMChipGet{dto.CIMChipGet{CanBeFRUed:false, CreationClassName:"", ElementName:"", Manufacturer:"", OperationalStatus:[]int(nil), Tag:"", Version:""}}}, CIMCard:dto.CIMCard{Response:dto.CIMCardResponseGet{CanBeFRUed:false, CreationClassName:"", ElementName:"", Manufacturer:"", Model:"", OperationalStatus:[]int(nil), PackageType:0, SerialNumber:"", Tag:"", Version:""}, Responses:[]interface {}(nil)}, CIMBIOSElement:dto.CIMBIOSElement{Response:dto.CIMBIOSElementResponse{TargetOperatingSystem:0, SoftwareElementID:"", SoftwareElementState:0, Name:"", OperationalStatus:[]int(nil), ElementName:"", Version:"", Manufacturer:"", PrimaryBIOS:false, ReleaseDate:dto.Time{DateTime:""}}, Responses:[]interface {}(nil)}, CIMProcessor:dto.CIMProcessor{Responses:[]dto.CIMProcessorResponse{dto.CIMProcessorResponse{DeviceID:"", CreationClassName:"", SystemName:"", SystemCreationClassName:"", ElementName:"", OperationalStatus:[]int(nil), HealthState:0, EnabledState:0, RequestedState:0, Role:"", Family:0, OtherFamilyDescription:"", UpgradeMethod:0, MaxClockSpeed:0, CurrentClockSpeed:0, Stepping:"", CPUStatus:0, ExternalBusClockSpeed:0}}}, CIMPhysicalPackage:dto.CIMPhysicalPackage{Responses:[]dto.CIMPhysicalPackageResponses(nil)}, CIMPhysicalMemory:dto.CIMPhysicalMemory{Responses:[]dto.CIMPhysicalMemoryResponse(nil)}, CIMMediaAccessDevice:dto.CIMMediaAccessDevice{Pull:[]interface {}(nil), Get:struct { Capabilities []int; CreationClassName string; DeviceID string; ElementName string; EnabledDefault int; EnabledState int; MaxMediaSize int; OperationalStatus []int; RequestedState int; Security int; SystemCreationClassName string; SystemName string }{Capabilities:[]int(nil), CreationClassName:"", DeviceID:"", ElementName:"", EnabledDefault:0, EnabledState:0, MaxMediaSize:0, OperationalStatus:[]int(nil), RequestedState:0, Security:0, SystemCreationClassName:"", SystemName:""}}},
err: nil,
},
{
Expand All @@ -290,7 +292,7 @@ func TestGetHardwareInfo(t *testing.T) {
GetByID(context.Background(), device.GUID, "").
Return(nil, ErrGeneral)
},
res: nil,
res: dto.HardwareInfoResults{},
err: devices.ErrGeneral,
},
{
Expand All @@ -302,14 +304,14 @@ func TestGetHardwareInfo(t *testing.T) {
Return(man2)
man2.EXPECT().
GetHardwareInfo().
Return(nil, ErrGeneral)
Return(wsman.HWResults{}, ErrGeneral)
},
repoMock: func(repo *mocks.MockDeviceManagementRepository) {
repo.EXPECT().
GetByID(context.Background(), device.GUID, "").
Return(device, nil)
},
res: nil,
res: dto.HardwareInfoResults{},
err: ErrGeneral,
},
}
Expand Down

0 comments on commit b7daaf4

Please # to comment.