Skip to content

Commit 79b05af

Browse files
core (grpc): correctly convert arrays & bools (#1329)
1 parent 0fdff64 commit 79b05af

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

lib/common/grpc-service.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ GrpcService.convertValue_ = function(value) {
322322
};
323323
} else if (is.boolean(value)) {
324324
convertedValue = {
325-
booleanValue: value
325+
boolValue: value
326326
};
327327
} else if (Buffer.isBuffer(value)) {
328328
convertedValue = {
@@ -344,7 +344,9 @@ GrpcService.convertValue_ = function(value) {
344344
};
345345
} else if (is.array(value)) {
346346
convertedValue = {
347-
listValue: value.map(GrpcService.convertValue_)
347+
listValue: {
348+
values: value.map(GrpcService.convertValue_)
349+
}
348350
};
349351
} else {
350352
throw new Error('Value of type ' + typeof value + ' not recognized.');

system-test/logging.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,12 @@ describe('Logging', function() {
243243
// object data
244244
log.entry({ delegate: 'my_username' }),
245245

246-
// null data
247-
log.entry({ nonValue: null }),
246+
// various data types
247+
log.entry({
248+
nonValue: null,
249+
boolValue: true,
250+
arrayValue: [ 1, 2, 3 ]
251+
}),
248252

249253
// nested object data
250254
log.entry({

test/common/grpc-service.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ describe('GrpcService', function() {
692692
});
693693

694694
assert.deepEqual(GrpcService.convertValue_(true), {
695-
booleanValue: true
695+
boolValue: true
696696
});
697697

698698
assert.strictEqual(
@@ -733,11 +733,13 @@ describe('GrpcService', function() {
733733
it('should convert arrays', function() {
734734
var convertedValue = GrpcService.convertValue_([1, 2, 3]);
735735

736-
assert.deepEqual(convertedValue.listValue, [
737-
GrpcService.convertValue_(1),
738-
GrpcService.convertValue_(2),
739-
GrpcService.convertValue_(3)
740-
]);
736+
assert.deepEqual(convertedValue.listValue, {
737+
values: [
738+
GrpcService.convertValue_(1),
739+
GrpcService.convertValue_(2),
740+
GrpcService.convertValue_(3)
741+
]
742+
});
741743
});
742744

743745
it('should throw if a type is not recognized', function() {

0 commit comments

Comments
 (0)