Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
194 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
var ironmq = require('../') | ||
|
||
var nock = require('nock') | ||
var test = require('tap').test | ||
|
||
var con = require('./constants.js') | ||
var token = con.token | ||
var proj_id = con.project | ||
var q_name = con.q_name | ||
|
||
if (con.proxy) { | ||
var req = nock('http://host.name') | ||
.matchHeader('authorization','OAuth ' + token) | ||
.matchHeader('content-type','application/json') | ||
.matchHeader('user-agent','IronMQ Node Client') | ||
.get( | ||
'/3/projects/' + proj_id + '/queues') | ||
.reply(200 | ||
,[{ Timestamper : {updated_at: 1327083607064000000 } | ||
, project_id : 'test_worked' | ||
, name : 'test_worked'}]) | ||
} | ||
|
||
|
||
test('ironmq.options', function(t) { | ||
ironmq(token | ||
,{host : 'host.name' | ||
, protocol : 'http' | ||
, ver : 3})(proj_id) | ||
.list(function(err, obj) { | ||
|
||
t.equal(obj[0].name(), 'test_worked') | ||
t.end() | ||
}) | ||
|
||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
var ironmq = require('../') | ||
|
||
var nock = require('nock') | ||
var test = require('tap').test | ||
|
||
var con = require('./constants.js') | ||
var token = con.token | ||
var project = con.project | ||
var q_name = con.queue | ||
|
||
if (con.proxy) { | ||
var req = nock('https://mq-aws-us-east-1.iron.io') | ||
.matchHeader('authorization','OAuth ' + token) | ||
.matchHeader('content-type','application/json') | ||
.matchHeader('user-agent','IronMQ Node Client') | ||
.get( | ||
'/1/projects/' + project + '/queues/' + q_name | ||
+ '/messages?n=1') | ||
.reply(200 | ||
, { body: 'this is a test' | ||
, id: '4f1752cd52549a7435005a6b' | ||
, messages: [{ id: '4f1752cd52549a7435005a6b' | ||
, timeout: 60 | ||
, body: 'this is a test'}] | ||
, timeout: 60 }) | ||
} | ||
|
||
test('queue.get', function(t) { | ||
|
||
var queue = ironmq(token) | ||
.projects(project) | ||
.queues(q_name) | ||
|
||
queue.get(1 | ||
, function(err, obj) { | ||
t.deepEqual(obj | ||
, [{id: '4f1752cd52549a7435005a6b' | ||
, timeout: 60 | ||
, body: 'this is a test' | ||
, del: obj[0].del}]) | ||
|
||
t.end() | ||
}) | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
var ironmq = require('../') | ||
|
||
var nock = require('nock') | ||
var test = require('tap').test | ||
|
||
var con = require('./constants.js') | ||
var token = con.token | ||
var project = con.project | ||
var q_name = con.queue | ||
|
||
if (con.proxy) { | ||
var req = nock('https://mq-aws-us-east-1.iron.io') | ||
.matchHeader('authorization','OAuth ' + token) | ||
.matchHeader('content-type','application/json') | ||
.matchHeader('user-agent','IronMQ Node Client') | ||
.post( | ||
'/1/projects/' + project + '/queues/' + q_name + '/messages' | ||
, {"messages" : [ { some: 'option', body: 'this is a test' } | ||
, { some: 'option', body: 'another test' } | ||
, { some: 'option', body: 'one last test' }]}) | ||
.reply(200 | ||
, { ids: ['4f231f0fef05207255008f4a' | ||
, '4f231f0fef05207255008f4b' | ||
, '4f231f0fef05207255008f4c'] | ||
, msg: 'Messages put on queue.' }) | ||
} | ||
|
||
|
||
test('queue.put([], func)', function(t) { | ||
|
||
var client = ironmq(token) | ||
var queue = client | ||
.projects(project) | ||
.queues(q_name) | ||
|
||
queue.put([ | ||
'this is a test' | ||
, 'another test' | ||
, 'one last test'] | ||
, {some: 'option'} | ||
, function(err, obj) { | ||
t.deepEqual(obj | ||
, { ids: ['4f231f0fef05207255008f4a' | ||
, '4f231f0fef05207255008f4b' | ||
, '4f231f0fef05207255008f4c'] | ||
, msg: 'Messages put on queue.'}) | ||
t.end() | ||
}) | ||
|
||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
var ironmq = require('../') | ||
|
||
var nock = require('nock') | ||
var test = require('tap').test | ||
|
||
var con = require('./constants.js') | ||
var token = con.token | ||
var project = con.project | ||
var q_name = con.queue | ||
|
||
if (con.proxy) { | ||
var req = nock('https://mq-aws-us-east-1.iron.io') | ||
.matchHeader('authorization','OAuth ' + token) | ||
.matchHeader('content-type','application/json') | ||
.matchHeader('user-agent','IronMQ Node Client') | ||
.post( | ||
'/1/projects/' + project + '/queues/' + q_name + '/messages' | ||
, {"messages" : [ { body: 'this is a test' } | ||
, { body: 'another test' } | ||
, { body: 'one last test' }]}) | ||
.reply(200 | ||
, { ids: ['4f231f0fef05207255008f4a' | ||
, '4f231f0fef05207255008f4b' | ||
, '4f231f0fef05207255008f4c'] | ||
, msg: 'Messages put on queue.' }) | ||
} | ||
|
||
|
||
test('queue.put([], func)', function(t) { | ||
|
||
var client = ironmq(token) | ||
var queue = client | ||
.projects(project) | ||
.queues(q_name) | ||
|
||
queue.put([ | ||
'this is a test' | ||
, 'another test' | ||
, 'one last test'] | ||
, function(err, obj) { | ||
t.deepEqual(obj | ||
, { ids: ['4f231f0fef05207255008f4a' | ||
, '4f231f0fef05207255008f4b' | ||
, '4f231f0fef05207255008f4c'] | ||
, msg: 'Messages put on queue.'}) | ||
t.end() | ||
}) | ||
|
||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,5 @@ test('queue.put(str, {}, func)', function(t) { | |
|
||
|
||
//TODO | ||
// [msgs], cb | ||
// msg, not object, cb -> throw error | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters