protected variableValueToString()

in packages/autorest.gotest/src/generator/scenarioTestGenerator.ts [186:221]


  protected variableValueToString(key: string, variable: Variable, replaceGlobal = true): VariableOutput {
    let type: string, value: string;
    if (variable.type === 'string' || variable.type === 'secureString') {
      type = 'string';
      if (variable.value !== undefined) {
        value = this.getStringValue(variable.value);
      } else if (variable.prefix !== undefined) {
        type = 'prefix-string';
        value = this.getStringValue(variable.prefix);
      }
    } else if (variable.type === 'bool') {
      type = 'bool';
      if (variable.value !== undefined) {
        value = variable.value ? 'true' : 'false';
      }
    } else if (variable.type === 'int') {
      type = 'int';
      if (variable.value !== undefined) {
        value = variable.value + '';
      }
    } else if (variable.type === 'array') {
      type = '[]any';
      if (variable.value !== undefined) {
        value = this.arrayToString(variable.value);
      }
    } else if (variable.type === 'object' || variable.type === 'secureObject') {
      type = 'map[string]any';
      if (variable.value !== undefined) {
        value = this.objectToString(variable.value);
      }
    }
    if (replaceGlobal && variable.value === undefined && Object.prototype.hasOwnProperty.call(this.globalVariables, key)) {
      value = this.packagePrefixForGlobalVariables + key;
    }
    return new VariableOutput(type, value);
  }