Skip to content

Commit

Permalink
test(endpoints): read serviceId from service model
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr committed Aug 9, 2024
1 parent a360f3e commit a50628b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
13 changes: 6 additions & 7 deletions tests/endpoints-2.0/endpoints-integration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { EndpointParameters, EndpointV2 } from "@smithy/types";
import * as fs from "fs";
import * as path from "path";

import { EndpointExpectation, EndpointTestCase, ServiceModel, ServiceNamespace } from "./integration-test-types";
import { EndpointExpectation, ServiceModel, ServiceNamespace } from "./integration-test-types";

describe("client list", () => {
const root = path.join(__dirname, "..", "..");
Expand Down Expand Up @@ -40,7 +40,7 @@ describe("client list", () => {
for (const value of Object.values(model.shapes)) {
if (typeof value === "object" && value !== null && "type" in value && value.type === "service") {
const service = value as ServiceModel;
runTestCases(service, namespace, defaultEndpointResolver, "");
runTestCases(service, namespace, defaultEndpointResolver);
break;
}
}
Expand All @@ -53,12 +53,11 @@ describe("client list", () => {
function runTestCases(
service: ServiceModel,
namespace: ServiceNamespace,
defaultEndpointResolver: (endpointParams: EndpointParameters) => EndpointV2,
serviceId: string
defaultEndpointResolver: (endpointParams: EndpointParameters) => EndpointV2
) {
const [, tests] = Object.entries(service.traits).find(([k, v]) => k === "smithy.rules#endpointTests") as any;
if (tests?.testCases) {
const testCases = tests.testCases as EndpointTestCase[];
const serviceId = service.traits["aws.api#service"].serviceId;
const testCases = service.traits["smithy.rules#endpointTests"]?.testCases;
if (testCases) {
for (const testCase of testCases) {
const { documentation, params = {}, expect: expectation, operationInputs } = testCase;

Expand Down
2 changes: 1 addition & 1 deletion tests/endpoints-2.0/integration-test-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export interface ServiceModel {
"aws.api#service": {
serviceId: string;
};
"smithy.rules#endpointTests": {
"smithy.rules#endpointTests"?: {
testCases: EndpointTestCase[];
};
};
Expand Down

0 comments on commit a50628b

Please sign in to comment.