Skip to content

Commit

Permalink
add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mdutka-dell committed Oct 27, 2023
1 parent 2007ba8 commit 35f1f13
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/dell/csi-unity
go 1.21

require (
github.com/container-storage-interface/spec v1.5.0
github.com/container-storage-interface/spec v1.6.0
github.com/cucumber/godog v0.10.0
github.com/dell/dell-csi-extensions/podmon v1.2.0
github.com/dell/gobrick v1.9.0
Expand Down
2 changes: 1 addition & 1 deletion service/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ func (s *service) getMaximumVolumeSize(ctx context.Context, arrayID string) int6
log.Debugf("GetMaxVolumeSize returning: %v for Array having GlobalId %s", err, arrayID)
return 0
}
return maxVolumeSize
return maxVolumeSize.MaxVolumSizeContent.Limit
}

func (s *service) CreateSnapshot(ctx context.Context, req *csi.CreateSnapshotRequest) (*csi.CreateSnapshotResponse, error) {
Expand Down
31 changes: 31 additions & 0 deletions test/unit-test/unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ type feature struct {
createSnapshotResponse *csi.CreateSnapshotResponse
deleteSnapshotRequest *csi.DeleteSnapshotRequest
deleteSnapshotResponse *csi.DeleteSnapshotResponse
getCapacityRequest *csi.GetCapacityRequest
getCapacityResponse *csi.GetCapacityResponse
capability *csi.VolumeCapability
capabilities []*csi.VolumeCapability
validateVolumeCapabilitiesRequest *csi.ValidateVolumeCapabilitiesRequest
Expand Down Expand Up @@ -1242,6 +1244,35 @@ func (f *feature) nodeExpandVolume(volID, volPath string) error {
return err
}

func (f *feature) whenICallGetCapacity() {
ctx := context.Background()
client := csi.NewControllerClient(grpcClient)

capability := new(csi.VolumeCapability)
mount := new(csi.VolumeCapability_MountVolume)
mountType := new(csi.VolumeCapability_Mount)
mountType.Mount = mount
capability.AccessType = mountType
accessMode := new(csi.VolumeCapability_AccessMode)
accessMode.Mode = csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER
capability.AccessMode = accessMode
f.capability = capability
capabilities := make([]*csi.VolumeCapability, 0)
capabilities = append(capabilities, capability)

f.getCapacityRequest = &csi.GetCapacityRequest{VolumeCapabilities: capabilities}
response, err := client.GetCapacity(ctx, f.getCapacityRequest)
if err != nil {
fmt.Printf("GetCapacity %s:\n", err.Error())
f.addError(err)
}
if err == nil {
fmt.Printf("Snapshot ID: %d \n", response.MaximumVolumeSize)
}

f.getCapacityResponse = response
}

func FeatureContext(s *godog.Suite) {
f := &feature{}
s.Step(`^a CSI service$`, f.aCSIService)
Expand Down

0 comments on commit 35f1f13

Please sign in to comment.