File tree 2 files changed +28
-1
lines changed
2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -1250,7 +1250,7 @@ func validateCPUCount(drvName string) {
1250
1250
}
1251
1251
1252
1252
// validateFlags validates the supplied flags against known bad combinations
1253
- func validateFlags (cmd * cobra.Command , drvName string ) {
1253
+ func validateFlags (cmd * cobra.Command , drvName string ) { //nolint:gocyclo
1254
1254
if cmd .Flags ().Changed (humanReadableDiskSize ) {
1255
1255
err := validateDiskSize (viper .GetString (humanReadableDiskSize ))
1256
1256
if err != nil {
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ import (
20
20
"fmt"
21
21
"strings"
22
22
"testing"
23
+ "time"
23
24
24
25
"github.com/blang/semver/v4"
25
26
"github.com/spf13/cobra"
@@ -886,3 +887,29 @@ func TestValidateGPUs(t *testing.T) {
886
887
}
887
888
}
888
889
}
890
+
891
+ func TestValidateAutoPause (t * testing.T ) {
892
+ tests := []struct {
893
+ interval string
894
+ shouldError bool
895
+ }{
896
+ {"1m0s" , false },
897
+ {"5m" , false },
898
+ {"1s" , false },
899
+ {"0s" , true },
900
+ {"-2m" , true },
901
+ }
902
+ for _ , tc := range tests {
903
+ input , err := time .ParseDuration (tc .interval )
904
+ if err != nil {
905
+ t .Fatalf ("test has an invalid input duration of %q" , tc .interval )
906
+ }
907
+ err = validateAutoPauseInterval (input )
908
+ if err != nil && ! tc .shouldError {
909
+ t .Errorf ("interval of %q failed validation; expected it to pass: %v" , input , err )
910
+ }
911
+ if err == nil && tc .shouldError {
912
+ t .Errorf ("interval of %q passed validataion; expected it to fail: %v" , input , err )
913
+ }
914
+ }
915
+ }
You can’t perform that action at this time.
0 commit comments