@google-cloud/agones-sdk 1.55.0 → 1.56.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/biome.json +24 -0
- package/package.json +7 -7
- package/spec/agonesSDK.spec.js +481 -467
- package/spec/alphaAgonesSDK.spec.js +288 -254
- package/spec/betaAgonesSDK.spec.js +427 -419
- package/spec/support/jasmine.json +6 -8
- package/src/agonesSDK.d.ts +25 -22
- package/src/agonesSDK.js +13 -11
- package/src/alpha.d.ts +7 -7
- package/src/alpha.js +130 -130
- package/src/beta.d.ts +13 -13
- package/src/beta.js +248 -248
- package/src/index.d.ts +1 -1
- package/src/index.js +1 -1
- package/.eslintrc.json +0 -18
|
@@ -1,419 +1,427 @@
|
|
|
1
|
-
// Copyright 2020 Google LLC All Rights Reserved.
|
|
2
|
-
//
|
|
3
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
// you may not use this file except in compliance with the License.
|
|
5
|
-
// You may obtain a copy of the License at
|
|
6
|
-
//
|
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
//
|
|
9
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
// See the License for the specific language governing permissions and
|
|
13
|
-
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
const grpc = require(
|
|
16
|
-
|
|
17
|
-
const messages = require(
|
|
18
|
-
const Beta = require(
|
|
19
|
-
|
|
20
|
-
describe(
|
|
21
|
-
let beta;
|
|
22
|
-
|
|
23
|
-
beforeEach(() => {
|
|
24
|
-
const address =
|
|
25
|
-
const credentials = grpc.credentials.createInsecure();
|
|
26
|
-
beta = new Beta(address, credentials);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
describe(
|
|
30
|
-
it(
|
|
31
|
-
spyOn(beta.client,
|
|
32
|
-
|
|
33
|
-
counter.setCount(10);
|
|
34
|
-
callback(undefined, counter);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
expect(beta.client.getCounter).toHaveBeenCalled();
|
|
39
|
-
expect(count).toEqual(10);
|
|
40
|
-
|
|
41
|
-
expect(request.getName()).toEqual(
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it(
|
|
45
|
-
spyOn(beta.client,
|
|
46
|
-
callback(
|
|
47
|
-
});
|
|
48
|
-
try {
|
|
49
|
-
await beta.getCounterCount(
|
|
50
|
-
fail();
|
|
51
|
-
} catch (error) {
|
|
52
|
-
expect(beta.client.getCounter).toHaveBeenCalled();
|
|
53
|
-
expect(error).toEqual(
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
describe(
|
|
59
|
-
it(
|
|
60
|
-
spyOn(beta.client,
|
|
61
|
-
|
|
62
|
-
callback(undefined, counter);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
expect(beta.client.updateCounter).toHaveBeenCalled();
|
|
67
|
-
expect(response).toEqual(undefined);
|
|
68
|
-
|
|
69
|
-
expect(request.getCounterupdaterequest().getName()).toEqual(
|
|
70
|
-
expect(request.getCounterupdaterequest().getCountdiff()).toEqual(5);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it(
|
|
74
|
-
spyOn(beta.client,
|
|
75
|
-
callback(
|
|
76
|
-
});
|
|
77
|
-
try {
|
|
78
|
-
await beta.incrementCounter(
|
|
79
|
-
fail();
|
|
80
|
-
} catch (error) {
|
|
81
|
-
expect(beta.client.updateCounter).toHaveBeenCalled();
|
|
82
|
-
expect(error).toEqual(
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
describe(
|
|
88
|
-
it(
|
|
89
|
-
spyOn(beta.client,
|
|
90
|
-
|
|
91
|
-
callback(undefined, counter);
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
expect(beta.client.updateCounter).toHaveBeenCalled();
|
|
96
|
-
expect(response).toEqual(undefined);
|
|
97
|
-
|
|
98
|
-
expect(request.getCounterupdaterequest().getName()).toEqual(
|
|
99
|
-
expect(request.getCounterupdaterequest().getCountdiff()).toEqual(-5);
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
it(
|
|
103
|
-
spyOn(beta.client,
|
|
104
|
-
callback(
|
|
105
|
-
});
|
|
106
|
-
try {
|
|
107
|
-
await beta.decrementCounter(
|
|
108
|
-
fail();
|
|
109
|
-
} catch (error) {
|
|
110
|
-
expect(beta.client.updateCounter).toHaveBeenCalled();
|
|
111
|
-
expect(error).toEqual(
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
describe(
|
|
117
|
-
it(
|
|
118
|
-
spyOn(beta.client,
|
|
119
|
-
|
|
120
|
-
callback(undefined, counter);
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
expect(beta.client.updateCounter).toHaveBeenCalled();
|
|
125
|
-
expect(response).toEqual(undefined);
|
|
126
|
-
|
|
127
|
-
expect(request.getCounterupdaterequest().getName()).toEqual(
|
|
128
|
-
expect(request.getCounterupdaterequest().getCount().getValue()).toEqual(
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
expect(
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
expect(
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
expect(
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
expect(
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
1
|
+
// Copyright 2020 Google LLC All Rights Reserved.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
|
|
15
|
+
const grpc = require("@grpc/grpc-js");
|
|
16
|
+
|
|
17
|
+
const messages = require("../lib/beta/beta_pb");
|
|
18
|
+
const Beta = require("../src/beta");
|
|
19
|
+
|
|
20
|
+
describe("Beta", () => {
|
|
21
|
+
let beta;
|
|
22
|
+
|
|
23
|
+
beforeEach(() => {
|
|
24
|
+
const address = "localhost:9357";
|
|
25
|
+
const credentials = grpc.credentials.createInsecure();
|
|
26
|
+
beta = new Beta(address, credentials);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
describe("getCounterCount", () => {
|
|
30
|
+
it("calls the server and handles the response", async () => {
|
|
31
|
+
spyOn(beta.client, "getCounter").and.callFake((_request, callback) => {
|
|
32
|
+
const counter = new messages.Counter();
|
|
33
|
+
counter.setCount(10);
|
|
34
|
+
callback(undefined, counter);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const count = await beta.getCounterCount("key");
|
|
38
|
+
expect(beta.client.getCounter).toHaveBeenCalled();
|
|
39
|
+
expect(count).toEqual(10);
|
|
40
|
+
const request = beta.client.getCounter.calls.argsFor(0)[0];
|
|
41
|
+
expect(request.getName()).toEqual("key");
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("calls the server and handles failure", async () => {
|
|
45
|
+
spyOn(beta.client, "getCounter").and.callFake((_request, callback) => {
|
|
46
|
+
callback("error", undefined);
|
|
47
|
+
});
|
|
48
|
+
try {
|
|
49
|
+
await beta.getCounterCount("key");
|
|
50
|
+
fail();
|
|
51
|
+
} catch (error) {
|
|
52
|
+
expect(beta.client.getCounter).toHaveBeenCalled();
|
|
53
|
+
expect(error).toEqual("error");
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
describe("incrementCounter", () => {
|
|
59
|
+
it("calls the server and handles the response while under capacity", async () => {
|
|
60
|
+
spyOn(beta.client, "updateCounter").and.callFake((_request, callback) => {
|
|
61
|
+
const counter = new messages.Counter();
|
|
62
|
+
callback(undefined, counter);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const response = await beta.incrementCounter("key", 5);
|
|
66
|
+
expect(beta.client.updateCounter).toHaveBeenCalled();
|
|
67
|
+
expect(response).toEqual(undefined);
|
|
68
|
+
const request = beta.client.updateCounter.calls.argsFor(0)[0];
|
|
69
|
+
expect(request.getCounterupdaterequest().getName()).toEqual("key");
|
|
70
|
+
expect(request.getCounterupdaterequest().getCountdiff()).toEqual(5);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("calls the server and handles failure", async () => {
|
|
74
|
+
spyOn(beta.client, "updateCounter").and.callFake((_request, callback) => {
|
|
75
|
+
callback("error", undefined);
|
|
76
|
+
});
|
|
77
|
+
try {
|
|
78
|
+
await beta.incrementCounter("key", 5);
|
|
79
|
+
fail();
|
|
80
|
+
} catch (error) {
|
|
81
|
+
expect(beta.client.updateCounter).toHaveBeenCalled();
|
|
82
|
+
expect(error).toEqual("error");
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
describe("decrementCounter", () => {
|
|
88
|
+
it("calls the server and handles the response", async () => {
|
|
89
|
+
spyOn(beta.client, "updateCounter").and.callFake((_request, callback) => {
|
|
90
|
+
const counter = new messages.Counter();
|
|
91
|
+
callback(undefined, counter);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
const response = await beta.decrementCounter("key", 5);
|
|
95
|
+
expect(beta.client.updateCounter).toHaveBeenCalled();
|
|
96
|
+
expect(response).toEqual(undefined);
|
|
97
|
+
const request = beta.client.updateCounter.calls.argsFor(0)[0];
|
|
98
|
+
expect(request.getCounterupdaterequest().getName()).toEqual("key");
|
|
99
|
+
expect(request.getCounterupdaterequest().getCountdiff()).toEqual(-5);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("calls the server and handles failure", async () => {
|
|
103
|
+
spyOn(beta.client, "updateCounter").and.callFake((_request, callback) => {
|
|
104
|
+
callback("error", undefined);
|
|
105
|
+
});
|
|
106
|
+
try {
|
|
107
|
+
await beta.decrementCounter("key", 5);
|
|
108
|
+
fail();
|
|
109
|
+
} catch (error) {
|
|
110
|
+
expect(beta.client.updateCounter).toHaveBeenCalled();
|
|
111
|
+
expect(error).toEqual("error");
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
describe("setCounterCount", () => {
|
|
117
|
+
it("calls the server and handles the response", async () => {
|
|
118
|
+
spyOn(beta.client, "updateCounter").and.callFake((_request, callback) => {
|
|
119
|
+
const counter = new messages.Counter();
|
|
120
|
+
callback(undefined, counter);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
const response = await beta.setCounterCount("key", 5);
|
|
124
|
+
expect(beta.client.updateCounter).toHaveBeenCalled();
|
|
125
|
+
expect(response).toEqual(undefined);
|
|
126
|
+
const request = beta.client.updateCounter.calls.argsFor(0)[0];
|
|
127
|
+
expect(request.getCounterupdaterequest().getName()).toEqual("key");
|
|
128
|
+
expect(request.getCounterupdaterequest().getCount().getValue()).toEqual(
|
|
129
|
+
5,
|
|
130
|
+
);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it("calls the server and handles failure", async () => {
|
|
134
|
+
spyOn(beta.client, "updateCounter").and.callFake((_request, callback) => {
|
|
135
|
+
callback("error", undefined);
|
|
136
|
+
});
|
|
137
|
+
try {
|
|
138
|
+
await beta.setCounterCount("key", 5);
|
|
139
|
+
fail();
|
|
140
|
+
} catch (error) {
|
|
141
|
+
expect(beta.client.updateCounter).toHaveBeenCalled();
|
|
142
|
+
expect(error).toEqual("error");
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
describe("getCounterCapacity", () => {
|
|
148
|
+
it("calls the server and handles the response", async () => {
|
|
149
|
+
spyOn(beta.client, "getCounter").and.callFake((_request, callback) => {
|
|
150
|
+
const counter = new messages.Counter();
|
|
151
|
+
counter.setCapacity(10);
|
|
152
|
+
callback(undefined, counter);
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
const capacity = await beta.getCounterCapacity("key");
|
|
156
|
+
expect(beta.client.getCounter).toHaveBeenCalled();
|
|
157
|
+
expect(capacity).toEqual(10);
|
|
158
|
+
const request = beta.client.getCounter.calls.argsFor(0)[0];
|
|
159
|
+
expect(request.getName()).toEqual("key");
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
it("calls the server and handles failure", async () => {
|
|
163
|
+
spyOn(beta.client, "getCounter").and.callFake((_request, callback) => {
|
|
164
|
+
callback("error", undefined);
|
|
165
|
+
});
|
|
166
|
+
try {
|
|
167
|
+
await beta.getCounterCapacity("key");
|
|
168
|
+
fail();
|
|
169
|
+
} catch (error) {
|
|
170
|
+
expect(beta.client.getCounter).toHaveBeenCalled();
|
|
171
|
+
expect(error).toEqual("error");
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
describe("setCounterCapacity", () => {
|
|
177
|
+
it("calls the server and handles the response", async () => {
|
|
178
|
+
spyOn(beta.client, "updateCounter").and.callFake((_request, callback) => {
|
|
179
|
+
const counter = new messages.Counter();
|
|
180
|
+
callback(undefined, counter);
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
const response = await beta.setCounterCapacity("key", 5);
|
|
184
|
+
expect(beta.client.updateCounter).toHaveBeenCalled();
|
|
185
|
+
expect(response).toEqual(undefined);
|
|
186
|
+
const request = beta.client.updateCounter.calls.argsFor(0)[0];
|
|
187
|
+
expect(request.getCounterupdaterequest().getName()).toEqual("key");
|
|
188
|
+
expect(
|
|
189
|
+
request.getCounterupdaterequest().getCapacity().getValue(),
|
|
190
|
+
).toEqual(5);
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
it("calls the server and handles failure", async () => {
|
|
194
|
+
spyOn(beta.client, "updateCounter").and.callFake((_request, callback) => {
|
|
195
|
+
callback("error", undefined);
|
|
196
|
+
});
|
|
197
|
+
try {
|
|
198
|
+
await beta.setCounterCapacity("key", 5);
|
|
199
|
+
fail();
|
|
200
|
+
} catch (error) {
|
|
201
|
+
expect(beta.client.updateCounter).toHaveBeenCalled();
|
|
202
|
+
expect(error).toEqual("error");
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
describe("getListCapacity", () => {
|
|
208
|
+
it("calls the server and handles the response", async () => {
|
|
209
|
+
spyOn(beta.client, "getList").and.callFake((_request, callback) => {
|
|
210
|
+
const list = new messages.List();
|
|
211
|
+
list.setCapacity(10);
|
|
212
|
+
callback(undefined, list);
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
const capacity = await beta.getListCapacity("key");
|
|
216
|
+
expect(beta.client.getList).toHaveBeenCalled();
|
|
217
|
+
expect(capacity).toEqual(10);
|
|
218
|
+
const request = beta.client.getList.calls.argsFor(0)[0];
|
|
219
|
+
expect(request.getName()).toEqual("key");
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
it("calls the server and handles failure", async () => {
|
|
223
|
+
spyOn(beta.client, "getList").and.callFake((_request, callback) => {
|
|
224
|
+
callback("error", undefined);
|
|
225
|
+
});
|
|
226
|
+
try {
|
|
227
|
+
await beta.getListCapacity("key");
|
|
228
|
+
fail();
|
|
229
|
+
} catch (error) {
|
|
230
|
+
expect(beta.client.getList).toHaveBeenCalled();
|
|
231
|
+
expect(error).toEqual("error");
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
describe("setListCapacity", () => {
|
|
237
|
+
it("calls the server and handles the response while in range", async () => {
|
|
238
|
+
spyOn(beta.client, "updateList").and.callFake((_request, callback) => {
|
|
239
|
+
const list = new messages.List();
|
|
240
|
+
callback(undefined, list);
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
const response = await beta.setListCapacity("key", 5);
|
|
244
|
+
expect(beta.client.updateList).toHaveBeenCalled();
|
|
245
|
+
expect(response).toEqual(undefined);
|
|
246
|
+
const request = beta.client.updateList.calls.argsFor(0)[0];
|
|
247
|
+
expect(request.getList().getName()).toEqual("key");
|
|
248
|
+
expect(request.getList().getCapacity()).toEqual(5);
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
it("calls the server and handles failure", async () => {
|
|
252
|
+
spyOn(beta.client, "updateList").and.callFake((_request, callback) => {
|
|
253
|
+
callback("error", undefined);
|
|
254
|
+
});
|
|
255
|
+
try {
|
|
256
|
+
await beta.setListCapacity("key", 5);
|
|
257
|
+
fail();
|
|
258
|
+
} catch (error) {
|
|
259
|
+
expect(beta.client.updateList).toHaveBeenCalled();
|
|
260
|
+
expect(error).toEqual("error");
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
describe("listContains", () => {
|
|
266
|
+
it("calls the server and handles the response when the value is contained", async () => {
|
|
267
|
+
spyOn(beta.client, "getList").and.callFake((_request, callback) => {
|
|
268
|
+
const list = new messages.List();
|
|
269
|
+
list.setValuesList(["firstValue", "secondValue"]);
|
|
270
|
+
callback(undefined, list);
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
const contains = await beta.listContains("key", "secondValue");
|
|
274
|
+
expect(beta.client.getList).toHaveBeenCalled();
|
|
275
|
+
expect(contains).toEqual(true);
|
|
276
|
+
const request = beta.client.getList.calls.argsFor(0)[0];
|
|
277
|
+
expect(request.getName()).toEqual("key");
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
it("calls the server and handles the response when the value is not contained", async () => {
|
|
281
|
+
spyOn(beta.client, "getList").and.callFake((_request, callback) => {
|
|
282
|
+
const list = new messages.List();
|
|
283
|
+
list.setValuesList(["firstValue", "secondValue"]);
|
|
284
|
+
callback(undefined, list);
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
const contains = await beta.listContains("key", "thirdValue");
|
|
288
|
+
expect(beta.client.getList).toHaveBeenCalled();
|
|
289
|
+
expect(contains).toEqual(false);
|
|
290
|
+
const request = beta.client.getList.calls.argsFor(0)[0];
|
|
291
|
+
expect(request.getName()).toEqual("key");
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
it("calls the server and handles failure", async () => {
|
|
295
|
+
spyOn(beta.client, "getList").and.callFake((_request, callback) => {
|
|
296
|
+
callback("error", undefined);
|
|
297
|
+
});
|
|
298
|
+
try {
|
|
299
|
+
await beta.listContains("key", "value");
|
|
300
|
+
fail();
|
|
301
|
+
} catch (error) {
|
|
302
|
+
expect(beta.client.getList).toHaveBeenCalled();
|
|
303
|
+
expect(error).toEqual("error");
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
describe("getListLength", () => {
|
|
309
|
+
it("calls the server and handles the response", async () => {
|
|
310
|
+
spyOn(beta.client, "getList").and.callFake((_request, callback) => {
|
|
311
|
+
const list = new messages.List();
|
|
312
|
+
list.setValuesList(["firstValue", "secondValue"]);
|
|
313
|
+
callback(undefined, list);
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
const length = await beta.getListLength("key");
|
|
317
|
+
expect(beta.client.getList).toHaveBeenCalled();
|
|
318
|
+
expect(length).toEqual(2);
|
|
319
|
+
const request = beta.client.getList.calls.argsFor(0)[0];
|
|
320
|
+
expect(request.getName()).toEqual("key");
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
it("calls the server and handles failure", async () => {
|
|
324
|
+
spyOn(beta.client, "getList").and.callFake((_request, callback) => {
|
|
325
|
+
callback("error", undefined);
|
|
326
|
+
});
|
|
327
|
+
try {
|
|
328
|
+
await beta.getListLength("key");
|
|
329
|
+
fail();
|
|
330
|
+
} catch (error) {
|
|
331
|
+
expect(beta.client.getList).toHaveBeenCalled();
|
|
332
|
+
expect(error).toEqual("error");
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
describe("getListValues", () => {
|
|
338
|
+
it("calls the server and handles the response", async () => {
|
|
339
|
+
spyOn(beta.client, "getList").and.callFake((_request, callback) => {
|
|
340
|
+
const list = new messages.List();
|
|
341
|
+
list.setValuesList(["firstValue", "secondValue"]);
|
|
342
|
+
callback(undefined, list);
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
const values = await beta.getListValues("key");
|
|
346
|
+
expect(beta.client.getList).toHaveBeenCalled();
|
|
347
|
+
expect(values).toEqual(["firstValue", "secondValue"]);
|
|
348
|
+
const request = beta.client.getList.calls.argsFor(0)[0];
|
|
349
|
+
expect(request.getName()).toEqual("key");
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
it("calls the server and handles failure", async () => {
|
|
353
|
+
spyOn(beta.client, "getList").and.callFake((_request, callback) => {
|
|
354
|
+
callback("error", undefined);
|
|
355
|
+
});
|
|
356
|
+
try {
|
|
357
|
+
await beta.getListValues("key");
|
|
358
|
+
fail();
|
|
359
|
+
} catch (error) {
|
|
360
|
+
expect(beta.client.getList).toHaveBeenCalled();
|
|
361
|
+
expect(error).toEqual("error");
|
|
362
|
+
}
|
|
363
|
+
});
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
describe("appendListValue", () => {
|
|
367
|
+
it("calls the server and handles the response", async () => {
|
|
368
|
+
spyOn(beta.client, "addListValue").and.callFake((_request, callback) => {
|
|
369
|
+
const list = new messages.List();
|
|
370
|
+
callback(undefined, list);
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
const response = await beta.appendListValue("key", "value");
|
|
374
|
+
expect(beta.client.addListValue).toHaveBeenCalled();
|
|
375
|
+
expect(response).toEqual(undefined);
|
|
376
|
+
const request = beta.client.addListValue.calls.argsFor(0)[0];
|
|
377
|
+
expect(request.getName()).toEqual("key");
|
|
378
|
+
expect(request.getValue()).toEqual("value");
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
it("calls the server and handles failure", async () => {
|
|
382
|
+
spyOn(beta.client, "addListValue").and.callFake((_request, callback) => {
|
|
383
|
+
callback("error", undefined);
|
|
384
|
+
});
|
|
385
|
+
try {
|
|
386
|
+
await beta.appendListValue("key", "value");
|
|
387
|
+
fail();
|
|
388
|
+
} catch (error) {
|
|
389
|
+
expect(beta.client.addListValue).toHaveBeenCalled();
|
|
390
|
+
expect(error).toEqual("error");
|
|
391
|
+
}
|
|
392
|
+
});
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
describe("deleteListValue", () => {
|
|
396
|
+
it("calls the server and handles the response", async () => {
|
|
397
|
+
spyOn(beta.client, "removeListValue").and.callFake(
|
|
398
|
+
(_request, callback) => {
|
|
399
|
+
const list = new messages.List();
|
|
400
|
+
callback(undefined, list);
|
|
401
|
+
},
|
|
402
|
+
);
|
|
403
|
+
|
|
404
|
+
const response = await beta.deleteListValue("key", "value");
|
|
405
|
+
expect(beta.client.removeListValue).toHaveBeenCalled();
|
|
406
|
+
expect(response).toEqual(undefined);
|
|
407
|
+
const request = beta.client.removeListValue.calls.argsFor(0)[0];
|
|
408
|
+
expect(request.getName()).toEqual("key");
|
|
409
|
+
expect(request.getValue()).toEqual("value");
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
it("calls the server and handles failure", async () => {
|
|
413
|
+
spyOn(beta.client, "removeListValue").and.callFake(
|
|
414
|
+
(_request, callback) => {
|
|
415
|
+
callback("error", undefined);
|
|
416
|
+
},
|
|
417
|
+
);
|
|
418
|
+
try {
|
|
419
|
+
await beta.deleteListValue("key", "value");
|
|
420
|
+
fail();
|
|
421
|
+
} catch (error) {
|
|
422
|
+
expect(beta.client.removeListValue).toHaveBeenCalled();
|
|
423
|
+
expect(error).toEqual("error");
|
|
424
|
+
}
|
|
425
|
+
});
|
|
426
|
+
});
|
|
427
|
+
});
|