1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

CamelConversion: fix to not convert string values (#30595)

This commit is contained in:
Jordan Borean 2017-09-20 13:03:45 +10:00 committed by GitHub
parent 838f39e76a
commit 1ea0293878
2 changed files with 2 additions and 5 deletions

View file

@ -30,8 +30,6 @@ Function Convert-ListToSnakeCase($list) {
$new_value = Convert-DictToSnakeCase -dict $value $new_value = Convert-DictToSnakeCase -dict $value
} elseif ($value -is [Array]) { } elseif ($value -is [Array]) {
$new_value = Convert-ListToSnakeCase -list $value $new_value = Convert-ListToSnakeCase -list $value
} elseif ($value -is [String]) {
$new_value = Convert-StringToSnakeCase -string $value
} else { } else {
$new_value = $value $new_value = $value
} }
@ -55,8 +53,6 @@ Function Convert-DictToSnakeCase($dict) {
$snake_dict.$snake_key = Convert-DictToSnakeCase -dict $value $snake_dict.$snake_key = Convert-DictToSnakeCase -dict $value
} elseif ($value -is [Array]) { } elseif ($value -is [Array]) {
$snake_dict.$snake_key = Convert-ListToSnakeCase -list $value $snake_dict.$snake_key = Convert-ListToSnakeCase -list $value
} elseif ($value -is [String]) {
$snake_dict.$snake_key = Convert-StringToSnakeCase -string $value
} else { } else {
$snake_dict.$snake_key = $value $snake_dict.$snake_key = $value
} }

View file

@ -51,7 +51,8 @@ foreach ($entry in $output_dict.GetEnumerator()) {
Assert-Equals -actual $inner_list_hash.Name -expected $inner_list_hash.Value Assert-Equals -actual $inner_list_hash.Name -expected $inner_list_hash.Value
} }
} elseif ($inner_list -is [String]) { } elseif ($inner_list -is [String]) {
Assert-Equals -actual $inner_list -expected "string_two" # this is not a string key so we need to keep it the same
Assert-Equals -actual $inner_list -expected "stringTwo"
} else { } else {
Assert-Equals -actual $inner_list -expected 0 Assert-Equals -actual $inner_list -expected 0
} }