Skip to content
Merged
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: feature
packages:
- "@azure-tools/azure-http-specs"
---

Add data plane test for combined multi service.
20 changes: 20 additions & 0 deletions packages/azure-http-specs/spec-summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -4216,3 +4216,23 @@ With the above two calls, we test the following configurations from this service
- A client generated from the second service spec can call the second deployment of a service with api version v2 with the updated changes

Tests that we can grow up an operation from accepting one required parameter to accepting a required parameter and an optional parameter.

### Service_MultiService_ServiceA_Foo_test

- Endpoint: `get /service/multi-service/service-a/foo/test`

Test that a client can expose operations from multiple services. This operaton should be called like this: `client.foo.test(...)`.

Expected path: /service/multi-service/service-a/foo/test
Expected query parameter: api-version=av2
Expected 204 response.

### Service_MultiService_ServiceB_Bar_test

- Endpoint: `get /service/multi-service/service-b/bar/test`

Test that a client can expose operations from multiple services. This operaton should be called like this: `client.bar.test(...)`.

Expected path: /service/multi-service/service-b/bar/test
Expected query parameter: api-version=bv2
Expected 204 response.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import "./main.tsp";
import "@azure-tools/typespec-client-generator-core";
import "@typespec/spector";
import "@typespec/http";
import "@typespec/versioning";

using Azure.ClientGenerator.Core;
using Spector;
using Versioning;

@client({
service: [Service.MultiService.ServiceA, Service.MultiService.ServiceB],
})
namespace Service.MultiService.Combined;
61 changes: 61 additions & 0 deletions packages/azure-http-specs/specs/service/multi-service/main.tsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import "@typespec/versioning";
import "@typespec/http";
import "@typespec/spector";

using Versioning;
using Http;
using Spector;

namespace Service.MultiService;

/*
* First service definition in a multi-service package with versioning
*/
@scenarioService("/service/multi-service/service-a")
@versioned(VersionsA)
namespace ServiceA {
enum VersionsA {
av1,
av2,
}

@route("foo")
interface Foo {
@scenario
@scenarioDoc("""
Test that a client can expose operations from multiple services. This operaton should be called like this: `client.foo.test(...)`.

Expected path: /service/multi-service/service-a/foo/test
Expected query parameter: api-version=av2
Expected 204 response.
""")
@route("/test")
test(@query("api-version") apiVersion: VersionsA): void;
}
}

/**
* Second service definition in a multi-service package with versioning
*/
@scenarioService("/service/multi-service/service-b")
@versioned(VersionsB)
namespace ServiceB {
enum VersionsB {
bv1,
bv2,
}

@route("bar")
interface Bar {
@scenario
@scenarioDoc("""
Test that a client can expose operations from multiple services. This operaton should be called like this: `client.bar.test(...)`.

Expected path: /service/multi-service/service-b/bar/test
Expected query parameter: api-version=bv2
Expected 204 response.
""")
@route("/test")
test(@query("api-version") apiVersion: VersionsB): void;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { passOnSuccess, ScenarioMockApi } from "@typespec/spec-api";

export const Scenarios: Record<string, ScenarioMockApi> = {};

Scenarios.Service_MultiService_ServiceA_Foo_test = passOnSuccess({
uri: "/service/multi-service/service-a/foo/test",
method: "get",
request: {
query: {
"api-version": "av2",
},
},
response: { status: 204 },
kind: "MockApiDefinition",
});

Scenarios.Service_MultiService_ServiceB_Bar_test = passOnSuccess({
uri: "/service/multi-service/service-b/bar/test",
method: "get",
request: {
query: {
"api-version": "bv2",
},
},
response: { status: 204 },
kind: "MockApiDefinition",
});
Loading