Skip to content

Commit

Permalink
test(endpoints): read tests from serviceModel
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr committed Aug 9, 2024
1 parent 8d6af17 commit c366769
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions tests/endpoints-2.0/endpoints-integration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,25 @@ describe("client list", () => {
const [, service] = Object.entries(model.shapes).find(
([k, v]) => typeof v === "object" && v !== null && "type" in v && v.type === "service"
) as any;
const [, tests] = Object.entries(service.traits).find(([k, v]) => k === "smithy.rules#endpointTests") as any;
if (tests?.testCases) {
runTestCases(tests, service, defaultEndpointResolver, "");
} else {
it.skip("has no test cases", () => {});
}
runTestCases(service, defaultEndpointResolver, "");
} else {
it.skip("unable to load endpoint resolver, or test cases", () => {});
}
});
});

function runTestCases(
{ testCases }: { testCases: EndpointTestCase[] },
service: ServiceNamespace,
defaultEndpointResolver: (endpointParams: EndpointParameters) => EndpointV2,
serviceId: string
) {
for (const testCase of testCases) {
runTestCase(testCase, service, defaultEndpointResolver, serviceId);
const [, tests] = Object.entries(service.traits).find(([k, v]) => k === "smithy.rules#endpointTests") as any;
if (tests?.testCases) {
for (const testCase of tests.testCases) {
runTestCase(testCase, service, defaultEndpointResolver, serviceId);
}
} else {
it.skip("has no test cases", () => {});
}
}

Expand Down

0 comments on commit c366769

Please sign in to comment.