From 9a2b04e9c2cfd807087328534fb7e701b60de54f Mon Sep 17 00:00:00 2001 From: Zhenglai Zhang Date: Thu, 21 Oct 2021 17:43:52 +0800 Subject: [PATCH] minor improvement for api scenario runner (#692) * minor improvement for api scenario runner * fix typo * remove cloudName default value to support customized armEndpoint * remove cloudName support to add its support in wrapper * update snapshot --- lib/apiScenario/markdownReport.ts | 8 ++++++-- test/apiScenario/__snapshots__/junitReportTest.ts.snap | 2 +- test/apiScenario/__snapshots__/markdownReportTest.ts.snap | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/apiScenario/markdownReport.ts b/lib/apiScenario/markdownReport.ts index df1485e5..5d4b7eec 100644 --- a/lib/apiScenario/markdownReport.ts +++ b/lib/apiScenario/markdownReport.ts @@ -7,6 +7,10 @@ import { ResponseDiffItem, RuntimeError, StepResult, TestScenarioResult } from " const spaceReg = /(\n|\t|\r)/gi; +const getErrorCodeDocLink = (code: string): string => { + return `https://github.com/Azure/azure-rest-api-specs/blob/main/documentation/api-scenario/references/ErrorCodeReference.md#${code}`; +}; + const commonHelper = (opts: HelperOpts) => ({ renderPlain: (s: string) => s, renderWhitespace: (n: number) => " ".repeat(n), @@ -56,9 +60,9 @@ const commonHelper = (opts: HelperOpts) => ({ `${hd.default(moment.duration(moment(end).diff(moment(start))).asMilliseconds())}`, shouldReportError: (sr: TestScenarioMarkdownStepResult) => sr.failedErrorsCount + sr.fatalErrorsCount > 0, - renderFatalErrorCode: (e: RuntimeError) => `[${e.code}]()`, + renderFatalErrorCode: (e: RuntimeError) => `[${e.code}](${getErrorCodeDocLink(e.code)})`, renderFatalErrorDetail: (e: RuntimeError) => `${e.message.replace(spaceReg, " ")}`, - renderDiffErrorCode: (e: ResponseDiffItem) => `[${e.code}]()`, + renderDiffErrorCode: (e: ResponseDiffItem) => `[${e.code}](${getErrorCodeDocLink(e.code)})`, renderDiffErrorDetail: (e: ResponseDiffItem) => `${e.message.replace(spaceReg, " ")}`, }); diff --git a/test/apiScenario/__snapshots__/junitReportTest.ts.snap b/test/apiScenario/__snapshots__/junitReportTest.ts.snap index 9f8fee43..26bc2c42 100644 --- a/test/apiScenario/__snapshots__/junitReportTest.ts.snap +++ b/test/apiScenario/__snapshots__/junitReportTest.ts.snap @@ -4,6 +4,6 @@ exports[`junitTestReport Should generate junit case report 1`] = ` "###Create or update a simple gallery with sharing profile.: 1 Fatal Error(s) | Rule | Message | |------|---------| -|[RUNTIME_ERROR_400]()|code: BadRequest, message: Subscription 'db5eb68e-73e2-4fa8-b18a-46cd1be4cce5' is not registered with the feature Microsoft.Compute/SIGSharing. Please register the subscription before retrying the call.| +|[RUNTIME_ERROR_400](https://github.com/Azure/azure-rest-api-specs/blob/main/documentation/api-scenario/references/ErrorCodeReference.md#RUNTIME_ERROR_400)|code: BadRequest, message: Subscription 'db5eb68e-73e2-4fa8-b18a-46cd1be4cce5' is not registered with the feature Microsoft.Compute/SIGSharing. Please register the subscription before retrying the call.| " `; diff --git a/test/apiScenario/__snapshots__/markdownReportTest.ts.snap b/test/apiScenario/__snapshots__/markdownReportTest.ts.snap index 329d6fe3..14c62a1a 100644 --- a/test/apiScenario/__snapshots__/markdownReportTest.ts.snap +++ b/test/apiScenario/__snapshots__/markdownReportTest.ts.snap @@ -62,7 +62,7 @@ exports[`markdownReport Should generate markdown report: body 1`] = ` |                           Rule                           | Message | |------|---------| -| [RUNTIME_ERROR_400]() | code: BadRequest, message: Subscription 'db5eb68e-73e2-4fa8-b18a-46cd1be4cce5' is not registered with the feature Microsoft.Compute/SIGSharing. Please register the subscription before retrying the call. | +| [RUNTIME_ERROR_400](https://github.com/Azure/azure-rest-api-specs/blob/main/documentation/api-scenario/references/ErrorCodeReference.md#RUNTIME_ERROR_400) | code: BadRequest, message: Subscription 'db5eb68e-73e2-4fa8-b18a-46cd1be4cce5' is not registered with the feature Microsoft.Compute/SIGSharing. Please register the subscription before retrying the call. |