Skip to content

Commit

Permalink
Fix example name issue (#866)
Browse files Browse the repository at this point in the history
* feat: refine example function name

* build: pump to @autorest/gotest_v4.2.2

* upgrade gotest ci go version to 1.19
  • Loading branch information
tadelesh committed Aug 19, 2022
1 parent 78d7d97 commit aa23215
Show file tree
Hide file tree
Showing 28 changed files with 155 additions and 133 deletions.
12 changes: 8 additions & 4 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions eng/pipelines/ci-gotest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ jobs:

strategy:
matrix:
Linux_Go118:
Linux_Go119:
vm.image: "ubuntu-18.04"
go.version: "1.18"
go.version: "1.19"

pool:
vmImage: "$(vm.image)"
Expand Down
2 changes: 1 addition & 1 deletion eng/pipelines/publish-release-gotest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ steps:
- template: ../steps/set-env.yaml
parameters:
NodeVersion: "16.x"
GoVersion: "1.18"
GoVersion: "1.19"

- template: ../steps/build-test-gotest.yaml

Expand Down
12 changes: 12 additions & 0 deletions packages/autorest.gotest/CHANGELOG.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
{
"name": "@autorest/gotest",
"entries": [
{
"version": "4.2.2",
"tag": "@autorest/gotest_v4.2.2",
"date": "Fri, 19 Aug 2022 02:39:29 GMT",
"comments": {
"patch": [
{
"comment": "Fix illegal example funtion name."
}
]
}
},
{
"version": "4.2.1",
"tag": "@autorest/gotest_v4.2.1",
Expand Down
9 changes: 8 additions & 1 deletion packages/autorest.gotest/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Change Log - @autorest/gotest

This log was last generated on Thu, 04 Aug 2022 09:20:24 GMT and should not be manually modified.
This log was last generated on Fri, 19 Aug 2022 02:39:29 GMT and should not be manually modified.

## 4.2.2
Fri, 19 Aug 2022 02:39:29 GMT

### Patches

- Fix illegal example funtion name.

## 4.2.1
Thu, 04 Aug 2022 09:20:24 GMT
Expand Down
6 changes: 3 additions & 3 deletions packages/autorest.gotest/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@autorest/gotest",
"version": "4.2.1",
"version": "4.2.2",
"description": "Autorest extension for go test generation",
"main": "dist/index.js",
"scripts": {
Expand Down Expand Up @@ -30,6 +30,7 @@
"license": "MIT",
"devDependencies": {
"@types/jest": "~26.0.24",
"@types/lodash": "^4.14.183",
"@types/node": "17.0.23",
"@typescript-eslint/eslint-plugin": "~4.1.1",
"@typescript-eslint/parser": "~4.1.1",
Expand All @@ -50,13 +51,12 @@
"@autorest/testmodeler": "~2.3.1",
"@azure-tools/codegen": "~2.9.1",
"@azure-tools/linq": "~3.1.0",
"@types/lodash": "~4.14.176",
"autorest": "^3.2.3",
"cross-env": "^7.0.3",
"jest-junit": "^12.2.0",
"js-yaml": "3.13.1",
"jsonpath": "^1.1.1",
"lodash": "~4.17.21",
"lodash": "^4.17.21",
"node-yaml": "^3.2.0",
"nunjucks": "^3.2.3",
"oav": "3.0.3",
Expand Down
7 changes: 3 additions & 4 deletions packages/autorest.gotest/src/generator/exampleGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Config } from '../common/constant';
import { ExampleModel, MockTestDefinitionModel } from '@autorest/testmodeler/dist/src/core/model';
import { MockTestDataRender } from './mockTestGenerator';
import { ParameterOutput } from '../common/model';
import path = require('path');
import { camelCase } from 'lodash';

export class ExampleDataRender extends MockTestDataRender {}

Expand Down Expand Up @@ -44,9 +44,8 @@ export class ExampleCodeGenerator extends BaseCodeGenerator {
})
.join(', ');
},
getExampleSuffix: (exampleFilename: string) => {
const name = path.parse(exampleFilename).name;
return name.charAt(0).toLowerCase() + name.slice(1);
getExampleSuffix: (exampleKey: string) => {
return camelCase(exampleKey);
},
},
);
Expand Down
2 changes: 1 addition & 1 deletion packages/autorest.gotest/src/template/exampleTest.go.njk
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
{%- if allExamples.indexOf(example.originalFile)<0 %}
{%- set _ = allExamples.push(example.originalFile) %}
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/{{example.originalFile}}
func Example{{example.operationGroup.language.go.clientName}}_{{example.opName}}{% if exampleGroup.examples.length>1 %}_{{jsFunc.getExampleSuffix(example.originalFile)}}{% endif %}() {
func Example{{example.operationGroup.language.go.clientName}}_{{example.opName}}{% if exampleGroup.examples.length>1 %}_{{jsFunc.getExampleSuffix(example.name)}}{% endif %}() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit aa23215

Please sign in to comment.