-
Notifications
You must be signed in to change notification settings - Fork 0
/
grpc.consumer.test.ts
45 lines (43 loc) 路 1.29 KB
/
grpc.consumer.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { PactBun, Pact } from "./pactBun";
const pact = new PactBun();
const pactContents = {
"pact:proto": `${process.cwd()}/proto/area_calculator.proto`,
"pact:proto-service": "Calculator/calculateOne",
"pact:content-type": "application/protobuf",
request: {
rectangle: {
length: "matching(number, 3)",
width: "matching(number, 4)",
},
},
response: { value: ["matching(number, 12)"] },
};
console.log(
"馃殌 Testing gRPC Area Calculator with Pact Protobuf Plugin 馃殌\n",
{
pactContents,
},
);
await pact
.setupLoggers()
// Arrange
.newPact("area-calculator-consumer", "area-calculator-provider")
.addMetaDataToPact(pact.getPactFfiVersion())
.newSyncMessageInteraction("A gRPC calculateOne request")
.setPactSpecification(Pact.PactSpecification.PactSpecification_V4)
.usingPactPlugin("protobuf")
.withInteractionContents(
Pact.InteractionPart.InteractionPart_Request,
"application/grpc",
pactContents,
)
.createMockServerForTransport("grpc")
.executeTest(async () => {
const expected = [12];
// Act
const mockServerPort = pact.getMockServerPort();
// const results = await getShapeMessage(mockServerPort);
// Assert
// assertEquals(results.value, expected);
})
.then((results: string) => console.log(results));