Skip to content

Commit

Permalink
Merge pull request #125 from atomist-skills/handle-int32-args
Browse files Browse the repository at this point in the history
[SDC-1169] parse int32 args correctly
  • Loading branch information
chrispatrick authored Jul 12, 2024
2 parents 62de5c9 + b4ce28a commit 4721790
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions policy/skills/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ func ParseIntArg(arg interface{}) int64 {
return parsedArgAsInt64
}

parsedArgAsInt32, ok := arg.(int32)
if ok {
return int64(parsedArgAsInt32)
}

parsedArgAsFloat, ok := arg.(float64)
if ok {
return int64(parsedArgAsFloat)
Expand Down
10 changes: 10 additions & 0 deletions policy/skills/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,16 @@ func TestParseIntArgs(t *testing.T) {
arg: int64(30),
want: 30,
},
{
name: "Parse int32 arg",
arg: int32(30),
want: 30,
},
{
name: "Parse float64 arg",
arg: float64(30),
want: 30,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit 4721790

Please sign in to comment.