Commit 0b607a38 authored by sergey's avatar sergey

add setVariable

parent 6c570ae0
...@@ -105,6 +105,10 @@ Context.prototype.getVariable = function (name, cb) { ...@@ -105,6 +105,10 @@ Context.prototype.getVariable = function (name, cb) {
this.send('GET VARIABLE ' + name + '\n', cb || function() { }); this.send('GET VARIABLE ' + name + '\n', cb || function() { });
}; };
Context.prototype.setVariable = function (name, value, cb) {
this.send('SET VARIABLE ' + name + ' ' + value + '\n', cb || function() { });
};
Context.prototype.answer = function (cb) { Context.prototype.answer = function (cb) {
this.send('ANSWER' + '\n', cb || function() { }); this.send('ANSWER' + '\n', cb || function() { });
}; };
......
...@@ -3,8 +3,8 @@ var Context = require('./context'); ...@@ -3,8 +3,8 @@ var Context = require('./context');
var agi = { var agi = {
state: require('./state'), state: require('./state'),
Context: Context, Context: Context,
createServer: function(handler) { createServer: function (handler) {
return require('net').createServer(function(stream) { return require('net').createServer(function (stream) {
var context = new Context(stream); var context = new Context(stream);
handler(context); handler(context);
}); });
......
...@@ -146,6 +146,13 @@ describe('Context', function() { ...@@ -146,6 +146,13 @@ describe('Context', function() {
}); });
}); });
describe('setVariable', function() {
it('sends correct command', function() {
this.context.setVariable('test', 'test');
expect(this.context.sent.join('')).to.eql('SET VARIABLE test test\n');
});
});
describe('getVariable', function() { describe('getVariable', function() {
it('sends correct command', function() { it('sends correct command', function() {
this.context.getVariable('test'); this.context.getVariable('test');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment