Skip to content
Snippets Groups Projects
Commit 198a1ad9 authored by murgatroid99's avatar murgatroid99
Browse files

Added user-agent setting code, and a test for it

parent 61e64781
No related branches found
No related tags found
No related merge requests found
......@@ -47,6 +47,7 @@ var Readable = stream.Readable;
var Writable = stream.Writable;
var Duplex = stream.Duplex;
var util = require('util');
var version = require('../package.json').version;
util.inherits(ClientWritableStream, Writable);
......@@ -517,7 +518,10 @@ function makeClientConstructor(methods, serviceName) {
callback(null, metadata);
};
}
if (!options) {
options = {};
}
options.GRPC_ARG_PRIMARY_USER_AGENT_STRING = 'grpc-node/' + version;
this.server_address = address.replace(/\/$/, '');
this.channel = new grpc.Channel(address, options);
this.auth_uri = this.server_address + '/' + serviceName;
......
......@@ -258,6 +258,16 @@ describe('Echo metadata', function() {
});
call.end();
});
it('shows the correct user-agent string', function(done) {
var version = require('../package.json').version;
var call = client.unary({}, function(err, data) {
assert.ifError(err);
}, {key: ['value']});
call.on('metadata', function(metadata) {
assert(_.startsWith(metadata['user-agent'], 'grpc-node/' + version));
done();
});
});
});
describe('Other conditions', function() {
var client;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment