-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix incorrect conversion between int types (#3205)
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
- Loading branch information
1 parent
227a815
commit 8058758
Showing
2 changed files
with
48 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package function | ||
|
||
import ( | ||
"gopkg.in/check.v1" | ||
|
||
"github.com/kanisterio/kanister/pkg/param" | ||
) | ||
|
||
type ScaleWorkloadSuite struct{} | ||
|
||
var _ = check.Suite(&ScaleWorkloadSuite{}) | ||
|
||
func (s *ScaleWorkloadSuite) TestSetArgs(c *check.C) { | ||
stsParams := ¶m.StatefulSetParams{} | ||
for _, tc := range []struct { | ||
replicas interface{} | ||
expectedReplicas int32 | ||
}{ | ||
{ | ||
replicas: 4, | ||
expectedReplicas: 4, | ||
}, | ||
{ | ||
replicas: 234324, | ||
expectedReplicas: 234324, | ||
}, | ||
{ | ||
replicas: 234324, | ||
expectedReplicas: 234324, | ||
}, | ||
{ | ||
replicas: 2147483647, | ||
expectedReplicas: 2147483647, // 2147483647 is the maximum value int32 can hold | ||
}, | ||
} { | ||
s := scaleWorkloadFunc{} | ||
err := s.setArgs(param.TemplateParams{ | ||
StatefulSet: stsParams, | ||
}, map[string]interface{}{ | ||
"replicas": tc.replicas, | ||
}) | ||
|
||
c.Assert(err, check.IsNil) | ||
c.Assert(s.replicas, check.Equals, tc.expectedReplicas) | ||
} | ||
} |