diff --git a/api/spec/json/remoteAccessConfigurations.json b/api/spec/json/remoteAccessConfigurations.json index 09ae215b1..686909706 100644 --- a/api/spec/json/remoteAccessConfigurations.json +++ b/api/spec/json/remoteAccessConfigurations.json @@ -105,7 +105,7 @@ "examples": { "go": [ { - "command": "c8y remoteaccess configurations update --device device01 --id 1 --name hello", + "command": "c8y remoteaccess configurations update --device device01 --id 1 --newName hello", "description": "Update an existing remote access configuration", "assertStdOut": { "json": { @@ -117,7 +117,7 @@ ], "powershell": [ { - "command": "Update-RemoteAccessConfiguration -Device device01 -Id 1 -Name hello", + "command": "Update-RemoteAccessConfiguration -Device device01 -Id 1 -NewName hello", "description": "Update an existing remote access configuration", "skipTest": true } diff --git a/api/spec/yaml/remoteAccessConfigurations.yaml b/api/spec/yaml/remoteAccessConfigurations.yaml index f6990e191..72fb0aac2 100644 --- a/api/spec/yaml/remoteAccessConfigurations.yaml +++ b/api/spec/yaml/remoteAccessConfigurations.yaml @@ -77,14 +77,14 @@ commands: powershell: Update-RemoteAccessConfiguration examples: go: - - command: c8y remoteaccess configurations update --device device01 --id 1 --name hello + - command: c8y remoteaccess configurations update --device device01 --id 1 --newName hello description: Update an existing remote access configuration assertStdOut: json: path: r//service/remoteaccess/devices/\d+/configurations/1$ skipTest: true powershell: - - command: Update-RemoteAccessConfiguration -Device device01 -Id 1 -Name hello + - command: Update-RemoteAccessConfiguration -Device device01 -Id 1 -NewName hello description: Update an existing remote access configuration skipTest: true method: PUT diff --git a/cmd/gen-tests/main.go b/cmd/gen-tests/main.go index f537100a7..c0a989b7a 100644 --- a/cmd/gen-tests/main.go +++ b/cmd/gen-tests/main.go @@ -301,7 +301,7 @@ func formatJsonAssertion(jsonAssertion map[string]string, propType string, prop if strings.HasSuffix(prop, ".data") || strings.EqualFold(propType, "json_custom") { data := make(map[string]interface{}) if err := jsonUtilities.ParseJSON(values[0], data); err != nil { - loggerS.Warnf("Could not parse shorthand json. %s", err) + loggerS.Warnf("Could not parse shorthand json. error=%s, data=%s", err, values[0]) return } diff --git a/pkg/cmd/remoteaccess/configurations/create_passthrough/create_passthrough.auto.go b/pkg/cmd/remoteaccess/configurations/create_passthrough/createPassthrough.auto.go similarity index 100% rename from pkg/cmd/remoteaccess/configurations/create_passthrough/create_passthrough.auto.go rename to pkg/cmd/remoteaccess/configurations/create_passthrough/createPassthrough.auto.go diff --git a/pkg/cmd/remoteaccess/configurations/create_telnet/create_telnet.auto.go b/pkg/cmd/remoteaccess/configurations/create_telnet/createTelnet.auto.go similarity index 100% rename from pkg/cmd/remoteaccess/configurations/create_telnet/create_telnet.auto.go rename to pkg/cmd/remoteaccess/configurations/create_telnet/createTelnet.auto.go diff --git a/pkg/cmd/remoteaccess/configurations/create_vnc/create_vnc.auto.go b/pkg/cmd/remoteaccess/configurations/create_vnc/createVnc.auto.go similarity index 100% rename from pkg/cmd/remoteaccess/configurations/create_vnc/create_vnc.auto.go rename to pkg/cmd/remoteaccess/configurations/create_vnc/createVnc.auto.go diff --git a/pkg/cmd/remoteaccess/configurations/create_webssh/create_webssh.auto.go b/pkg/cmd/remoteaccess/configurations/create_webssh/createWebssh.auto.go similarity index 100% rename from pkg/cmd/remoteaccess/configurations/create_webssh/create_webssh.auto.go rename to pkg/cmd/remoteaccess/configurations/create_webssh/createWebssh.auto.go diff --git a/pkg/cmd/remoteaccess/configurations/update/update.auto.go b/pkg/cmd/remoteaccess/configurations/update/update.auto.go index e25a6b0fa..67cdd8955 100644 --- a/pkg/cmd/remoteaccess/configurations/update/update.auto.go +++ b/pkg/cmd/remoteaccess/configurations/update/update.auto.go @@ -36,7 +36,7 @@ func NewUpdateCmd(f *cmdutil.Factory) *UpdateCmd { Hidden: true, Example: heredoc.Doc(` -$ c8y remoteaccess configurations update --device device01 --id 1 --name hello +$ c8y remoteaccess configurations update --device device01 --id 1 --newName hello Update an existing remote access configuration `), PreRunE: func(cmd *cobra.Command, args []string) error { diff --git a/scripts/build-cli-tests.sh b/scripts/build-cli-tests.sh index b20bed1da..28d59f843 100755 --- a/scripts/build-cli-tests.sh +++ b/scripts/build-cli-tests.sh @@ -1,4 +1,5 @@ -#!/bin/bash +#!/usr/bin/env bash +set -e #-------------------------------------------- # Generate the command tests from the specs #-------------------------------------------- @@ -6,13 +7,11 @@ # Delete existing folders to ensure there are no stale test files left behind rm -Rf ./tests/auto -for file in $( find ./api/spec \( -name "*.yml" -or -name "*.yaml" \) ) +while IFS= read -r -d '' file do - name=$( basename "$file" | sed -E 's/.ya?ml//g' | tr A-Z a-z ) - go run cmd/gen-tests/main.go "./tests/mocks.yaml" "$file" "./tests/auto/$name/tests" - code=$? - if [[ $code -ne 0 ]]; then - echo "Error code: $file, exit_code=$code" + name=$( basename "$file" | sed -E 's/.ya?ml//g' | tr '[:upper:]' '[:lower:]' ) + if ! go run cmd/gen-tests/main.go "./tests/mocks.yaml" "$file" "./tests/auto/$name/tests"; then + echo "Failed to generate cli tests: $file" >&2 + exit 1 fi - -done +done < <( find ./api/spec \( -name "*.yml" -or -name "*.yaml" \) -print0 ) diff --git a/scripts/build-cli/New-C8yApiGoCommand.ps1 b/scripts/build-cli/New-C8yApiGoCommand.ps1 index c94da2752..0363d9263 100644 --- a/scripts/build-cli/New-C8yApiGoCommand.ps1 +++ b/scripts/build-cli/New-C8yApiGoCommand.ps1 @@ -18,7 +18,7 @@ $NameCamel = ($Name[0].ToString().ToUpperInvariant() + $Name.Substring(1)) -replace '-(\p{L})', { $_.Groups[1].Value.ToUpper() } $PackageName = $Name.ToLower() -replace "-", "_" - $FileName = $PackageName + $FileName = $NameCamel[0].ToString().ToLowerInvariant() + $NameCamel.Substring(1) $File = Join-Path -Path $OutputDir -ChildPath ("{0}.auto.go" -f $FileName) diff --git a/tests/auto/remoteaccessconfigurations/tests/remoteaccess/configurations_update.yaml b/tests/auto/remoteaccessconfigurations/tests/remoteaccess/configurations_update.yaml index 13f48141c..f5aa49165 100644 --- a/tests/auto/remoteaccessconfigurations/tests/remoteaccess/configurations_update.yaml +++ b/tests/auto/remoteaccessconfigurations/tests/remoteaccess/configurations_update.yaml @@ -1,6 +1,6 @@ tests: remoteaccess/configurations_update_Update an existing remote access configuration: - command: c8y remoteaccess configurations update --device device01 --id 1 --name hello + command: c8y remoteaccess configurations update --device device01 --id 1 --newName hello exit-code: 0 skip: true stdout: