Skip to content

Commit f32e42d

Browse files
authored
[web-pubsub-client-protobuf] Add more tests (Azure#25183)
### Packages impacted by this PR eb-pubsub-client-protobuf ### Issues associated with this PR ### Describe the problem that is addressed by this PR Add more tests ### What are the possible designs available to address the problem? If there are more than one possible design, why was the one in this PR chosen? ### Are there test cases added in this PR? _(If not, why?)_ ### Provide a list of related PRs _(if any)_ ### Command used to generate this PR:**_(Applicable only to SDK release request PRs)_ ### Checklists - [ ] Added impacted package name to the issue description - [ ] Does this PR needs any fixes in the SDK Generator?** _(If so, create an Issue in the [Autorest/typescript](https://github.com/Azure/autorest.typescript) repository and link it here)_ - [ ] Added a changelog (if necessary)
1 parent a6fe3ff commit f32e42d

File tree

5 files changed

+318
-138
lines changed

5 files changed

+318
-138
lines changed

sdk/web-pubsub/web-pubsub-client-protobuf/src/generated/clientProto.d.ts

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/web-pubsub/web-pubsub-client-protobuf/src/generated/clientProto.js

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2570,11 +2570,11 @@ export const DownstreamMessage = $root.DownstreamMessage = (() => {
25702570

25712571
/**
25722572
* DataMessage sequenceId.
2573-
* @member {number|Long} sequenceId
2573+
* @member {number|Long|null|undefined} sequenceId
25742574
* @memberof DownstreamMessage.DataMessage
25752575
* @instance
25762576
*/
2577-
DataMessage.prototype.sequenceId = $util.Long ? $util.Long.fromBits(0,0,true) : 0;
2577+
DataMessage.prototype.sequenceId = null;
25782578

25792579
// OneOf field names bound to virtual getters and setters
25802580
let $oneOfFields;
@@ -2590,6 +2590,17 @@ export const DownstreamMessage = $root.DownstreamMessage = (() => {
25902590
set: $util.oneOfSetter($oneOfFields)
25912591
});
25922592

2593+
/**
2594+
* DataMessage _sequenceId.
2595+
* @member {"sequenceId"|undefined} _sequenceId
2596+
* @memberof DownstreamMessage.DataMessage
2597+
* @instance
2598+
*/
2599+
Object.defineProperty(DataMessage.prototype, "_sequenceId", {
2600+
get: $util.oneOfGetter($oneOfFields = ["sequenceId"]),
2601+
set: $util.oneOfSetter($oneOfFields)
2602+
});
2603+
25932604
/**
25942605
* Creates a new DataMessage instance using the specified properties.
25952606
* @function create
@@ -2721,9 +2732,11 @@ export const DownstreamMessage = $root.DownstreamMessage = (() => {
27212732
if (error)
27222733
return "data." + error;
27232734
}
2724-
if (message.sequenceId != null && message.hasOwnProperty("sequenceId"))
2735+
if (message.sequenceId != null && message.hasOwnProperty("sequenceId")) {
2736+
properties._sequenceId = 1;
27252737
if (!$util.isInteger(message.sequenceId) && !(message.sequenceId && $util.isInteger(message.sequenceId.low) && $util.isInteger(message.sequenceId.high)))
27262738
return "sequenceId: integer|Long expected";
2739+
}
27272740
return null;
27282741
};
27292742

@@ -2776,11 +2789,6 @@ export const DownstreamMessage = $root.DownstreamMessage = (() => {
27762789
if (options.defaults) {
27772790
object.from = "";
27782791
object.data = null;
2779-
if ($util.Long) {
2780-
let long = new $util.Long(0, 0, true);
2781-
object.sequenceId = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
2782-
} else
2783-
object.sequenceId = options.longs === String ? "0" : 0;
27842792
}
27852793
if (message.from != null && message.hasOwnProperty("from"))
27862794
object.from = message.from;
@@ -2791,11 +2799,14 @@ export const DownstreamMessage = $root.DownstreamMessage = (() => {
27912799
}
27922800
if (message.data != null && message.hasOwnProperty("data"))
27932801
object.data = $root.MessageData.toObject(message.data, options);
2794-
if (message.sequenceId != null && message.hasOwnProperty("sequenceId"))
2802+
if (message.sequenceId != null && message.hasOwnProperty("sequenceId")) {
27952803
if (typeof message.sequenceId === "number")
27962804
object.sequenceId = options.longs === String ? String(message.sequenceId) : message.sequenceId;
27972805
else
27982806
object.sequenceId = options.longs === String ? $util.Long.prototype.toString.call(message.sequenceId) : options.longs === Number ? new $util.LongBits(message.sequenceId.low >>> 0, message.sequenceId.high >>> 0).toNumber(true) : message.sequenceId;
2807+
if (options.oneofs)
2808+
object._sequenceId = "sequenceId";
2809+
}
27992810
return object;
28002811
};
28012812

sdk/web-pubsub/web-pubsub-client-protobuf/src/protos/client.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ message DownstreamMessage {
6161
string from = 1;
6262
optional string group = 2;
6363
MessageData data = 3;
64-
uint64 sequence_id = 4;
64+
optional uint64 sequence_id = 4;
6565
}
6666

6767
message SystemMessage {

sdk/web-pubsub/web-pubsub-client-protobuf/src/webPubSubProtobufProtocolBase.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ export class WebPubSubProtobufProtocolBase {
3333
*/
3434
public static parseMessages(input: ArrayBuffer): WebPubSubMessage | null {
3535
const downstream = DownstreamMessage.decode(new Uint8Array(input));
36-
// logger.verbose(`Receiving: ${JSON.stringify(downstream)}`);
3736
if (downstream.ackMessage) {
3837
const ack = {
3938
kind: "ack",
@@ -72,7 +71,7 @@ export class WebPubSubProtobufProtocolBase {
7271
data = messageData.textData;
7372
} else if (messageData.jsonData) {
7473
dataType = "json";
75-
data = messageData.jsonData;
74+
data = JSON.parse(messageData.jsonData);
7675
} else if (messageData.binaryData) {
7776
dataType = "binary";
7877
data = messageData.binaryData.buffer.slice(
@@ -81,7 +80,6 @@ export class WebPubSubProtobufProtocolBase {
8180
);
8281
} else if (messageData.protobufData) {
8382
dataType = "protobuf";
84-
// data = google.protobuf.Any.encode(messageData.protobufData).finish();
8583
data = messageData.protobufData;
8684
} else {
8785
return null;
@@ -115,7 +113,6 @@ export class WebPubSubProtobufProtocolBase {
115113
* @param message - The message to be written
116114
*/
117115
public static writeMessage(message: WebPubSubMessage): ArrayBuffer {
118-
// logger.verbose(`Writing: ${JSON.stringify(message)}`);
119116
let upstream: UpstreamMessage;
120117
switch (message.kind) {
121118
case "joinGroup": {

0 commit comments

Comments
 (0)