Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
Signed-off-by: Pierre-Emmanuel Jacquier <[email protected]>
  • Loading branch information
pierre-emmanuelJ committed Jan 23, 2024
1 parent 5040fd5 commit b04a43d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ go.work.sum
kubeconfig

release

bin/
11 changes: 5 additions & 6 deletions driver/helpers.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package driver

import (
"errors"
"fmt"
"os"
"path/filepath"
Expand Down Expand Up @@ -112,23 +111,23 @@ func getNewVolumeSize(capacityRange *csi.CapacityRange) (int64, error) {
}

if requiredSet && limitSet && limitBytes < requiredBytes {
return 0, errors.New("limit size is less than required size")
return 0, errLimitLessThanRequiredBytes

Check failure on line 114 in driver/helpers.go

View workflow job for this annotation

GitHub Actions / build

undefined: errLimitLessThanRequiredBytes

Check failure on line 114 in driver/helpers.go

View workflow job for this annotation

GitHub Actions / build

undefined: errLimitLessThanRequiredBytes

Check failure on line 114 in driver/helpers.go

View workflow job for this annotation

GitHub Actions / integ-tests

undefined: errLimitLessThanRequiredBytes
}

if requiredSet && !limitSet && requiredBytes < MinimalVolumeSizeBytes {
return 0, errors.New("required size is less than the minimun size")
return 0, errRequiredBytesLessThanMinimun

Check failure on line 118 in driver/helpers.go

View workflow job for this annotation

GitHub Actions / build

undefined: errRequiredBytesLessThanMinimun

Check failure on line 118 in driver/helpers.go

View workflow job for this annotation

GitHub Actions / build

undefined: errRequiredBytesLessThanMinimun

Check failure on line 118 in driver/helpers.go

View workflow job for this annotation

GitHub Actions / integ-tests

undefined: errRequiredBytesLessThanMinimun
}

if limitSet && limitBytes < MinimalVolumeSizeBytes {
return 0, errors.New("limit size is less than the minimun size")
return 0, errLimitLessThanMinimum

Check failure on line 122 in driver/helpers.go

View workflow job for this annotation

GitHub Actions / build

undefined: errLimitLessThanMinimum

Check failure on line 122 in driver/helpers.go

View workflow job for this annotation

GitHub Actions / build

undefined: errLimitLessThanMinimum

Check failure on line 122 in driver/helpers.go

View workflow job for this annotation

GitHub Actions / integ-tests

undefined: errLimitLessThanMinimum
}

if requiredSet && requiredBytes > MaximumVolumeSizeBytes {
return 0, errors.New("required size is greater than the maximum size")
return 0, errRequiredBytesGreaterThanMaximun

Check failure on line 126 in driver/helpers.go

View workflow job for this annotation

GitHub Actions / build

undefined: errRequiredBytesGreaterThanMaximun

Check failure on line 126 in driver/helpers.go

View workflow job for this annotation

GitHub Actions / build

undefined: errRequiredBytesGreaterThanMaximun

Check failure on line 126 in driver/helpers.go

View workflow job for this annotation

GitHub Actions / integ-tests

undefined: errRequiredBytesGreaterThanMaximun
}

if !requiredSet && limitSet && limitBytes > MaximumVolumeSizeBytes {
return 0, errors.New("limit size is greater than the maximum size")
return 0, errLimitGreaterThanMaximum

Check failure on line 130 in driver/helpers.go

View workflow job for this annotation

GitHub Actions / build

undefined: errLimitGreaterThanMaximum) (typecheck)

Check failure on line 130 in driver/helpers.go

View workflow job for this annotation

GitHub Actions / integ-tests

undefined: errLimitGreaterThanMaximum
}

if requiredSet && limitSet && requiredBytes == limitBytes {
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require (
github.com/container-storage-interface/spec v1.8.0
github.com/exoscale/egoscale v0.102.4-0.20240117105256-1ace995a320f
github.com/golang/protobuf v1.5.3
github.com/stretchr/testify v1.8.2
golang.org/x/sys v0.15.0
google.golang.org/grpc v1.58.0
google.golang.org/protobuf v1.31.0
Expand Down Expand Up @@ -39,6 +40,7 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/net v0.13.0 // indirect
golang.org/x/oauth2 v0.10.0 // indirect
Expand Down
7 changes: 7 additions & 0 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ github.com/modern-go/reflect2
# github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822
## explicit
github.com/munnerz/goautoneg
# github.com/pmezard/go-difflib v1.0.0
## explicit
github.com/pmezard/go-difflib/difflib
# github.com/stretchr/testify v1.8.2
## explicit; go 1.13
github.com/stretchr/testify/assert
github.com/stretchr/testify/require
# golang.org/x/crypto v0.17.0
## explicit; go 1.18
golang.org/x/crypto/sha3
Expand Down

0 comments on commit b04a43d

Please sign in to comment.