@@ -588,28 +588,15 @@ Describe 'Parameters tests' {
588588
589589 if ($type -eq ' string' ) {
590590 $value = " '$value '"
591- # For string type, only use length constraints
592- $config_yaml = @"
591+ }
592+
593+ $config_yaml = @"
593594 `$ schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
594595 parameters:
595596 param1:
596597 type: $type
597598 minLength: $min
598599 maxLength: $max
599- defaultValue: $value
600- resources:
601- - name: Echo
602- type: Microsoft.DSC.Debug/Echo
603- properties:
604- output: '[parameters(''param1'')]'
605- "@
606- } else {
607- # For int type, only use value constraints
608- $config_yaml = @"
609- `$ schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
610- parameters:
611- param1:
612- type: $type
613600 minValue: $min
614601 maxValue: $max
615602 defaultValue: $value
@@ -619,7 +606,6 @@ Describe 'Parameters tests' {
619606 properties:
620607 output: '[parameters(''param1'')]'
621608"@
622- }
623609
624610 $testError = & {$config_yaml | dsc config get -f - 2>&1 }
625611 $LASTEXITCODE | Should - Be 4
@@ -657,34 +643,25 @@ Describe 'Parameters tests' {
657643
658644 It ' Default values pass constraint validation for <type>' - TestCases @ (
659645 @ { type = ' string' ; value = ' admin' ; min = 3 ; max = 20 }
646+ @ { type = ' string' ; value = ' abc' ; min = 3 ; max = 20 }
647+ @ { type = ' string' ; value = ' abcdefghijklmnopqrst' ; min = 3 ; max = 20 }
660648 @ { type = ' int' ; value = 8080 ; min = 1 ; max = 65535 }
649+ @ { type = ' int' ; value = 1 ; min = 1 ; max = 65535 }
650+ @ { type = ' int' ; value = 65535 ; min = 1 ; max = 65535 }
661651 ) {
662652 param ($type , $value , $min , $max )
663653
664654 if ($type -eq ' string' ) {
665655 $value = " '$value '"
666- # For string type, only use length constraints
667- $config_yaml = @"
656+ }
657+
658+ $config_yaml = @"
668659 `$ schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
669660 parameters:
670661 param1:
671662 type: $type
672663 minLength: $min
673664 maxLength: $max
674- defaultValue: $value
675- resources:
676- - name: Echo
677- type: Microsoft.DSC.Debug/Echo
678- properties:
679- output: '[parameters(''param1'')]'
680- "@
681- } else {
682- # For int type, only use value constraints
683- $config_yaml = @"
684- `$ schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
685- parameters:
686- param1:
687- type: $type
688665 minValue: $min
689666 maxValue: $max
690667 defaultValue: $value
@@ -694,20 +671,17 @@ Describe 'Parameters tests' {
694671 properties:
695672 output: '[parameters(''param1'')]'
696673"@
697- }
698674
699675 $out = $config_yaml | dsc config get -f - | ConvertFrom-Json
700676 $LASTEXITCODE | Should - Be 0
701- if ($type -eq ' string' ) {
702- $out.results [0 ].result.actualState.output | Should - BeExactly ' admin'
703- } else {
704- $out.results [0 ].result.actualState.output | Should - BeExactly 8080
705- }
677+ $out.results [0 ].result.actualState.output | Should - BeExactly $value
706678 }
707679
708680 It ' Default values with allowedValues pass validation for <type>' - TestCases @ (
709681 @ { type = ' string' ; value = ' dev' ; allowed = @ (' dev' , ' test' , ' prod' ) }
682+ @ { type = ' string' ; value = ' prod' ; allowed = @ (' dev' , ' test' , ' prod' ) }
710683 @ { type = ' int' ; value = 5 ; allowed = @ (1 , 5 , 10 ) }
684+ @ { type = ' int' ; value = 10 ; allowed = @ (1 , 5 , 10 ) }
711685 ) {
712686 param ($type , $value , $allowed )
713687
@@ -731,10 +705,6 @@ Describe 'Parameters tests' {
731705
732706 $out = $config_yaml | dsc config get -f - | ConvertFrom-Json
733707 $LASTEXITCODE | Should - Be 0
734- if ($type -eq ' string' ) {
735- $out.results [0 ].result.actualState.output | Should - BeExactly ' dev'
736- } else {
737- $out.results [0 ].result.actualState.output | Should - BeExactly 5
738- }
708+ $out.results [0 ].result.actualState.output | Should - BeExactly $value
739709 }
740710}
0 commit comments