Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[test] tests for jitsu tokens methods

  • Loading branch information...
commit 23e6821479a3050ad3f48328352273f62ca9cd60 1 parent 4ed601c
@blakmatrix blakmatrix authored
Showing with 81 additions and 1 deletion.
  1. +0 −1  lib/jitsu/commands/tokens.js
  2. +81 −0 test/commands/tokens-test.js
View
1  lib/jitsu/commands/tokens.js
@@ -55,7 +55,6 @@ tokens.destroy = function (username, tokenName, callback) {
if(err){
callback(err);
} else {
- console.dir(arguments);
jitsu.log.info( 'Token '+ tokenName.yellow +' Destroyed!');
callback(null, tokenName);
}
View
81 test/commands/tokens-test.js
@@ -0,0 +1,81 @@
+/*
+ * apps-test.js: Tests for `jitsu apps *` command(s).
+ *
+ * (C) 2010, Nodejitsu Inc.
+ *
+ */
+
+var assert = require('assert'),
+ fs = require('fs'),
+ path = require('path'),
+ nock = require('nock'),
+ vows = require('vows'),
+ jitsu = require('../../lib/jitsu'),
+ macros = require('../helpers/macros');
+
+var shouldNodejitsuOk = macros.shouldNodejitsuOk,
+ useAppFixture = macros.useAppFixture;
+
+var mainDirectory = process.cwd();
+
+vows.describe('jitsu/commands/tokens').addBatch({
+ 'tokens list': shouldNodejitsuOk(function setup () {
+ nock('http://api.mockjitsu.com')
+ .get('/users/tester/tokens')
+ .reply(200, {"apiTokens":{}}, { 'x-powered-by': 'Nodejitsu' })
+ })
+}).addBatch({
+ 'tokens list adam': shouldNodejitsuOk( function setup () {
+ nock('http://api.mockjitsu.com')
+ .get('/users/adam/tokens')
+ .reply(200, {"apiTokens":{}}, { 'x-powered-by': 'Nodejitsu' });
+ })
+}).addBatch({
+ 'tokens create': shouldNodejitsuOk( function setup () {
+ nock('http://api.mockjitsu.com')
+ .post('/users/tester/tokens', {})
+ .reply(201, {"operation":"insert"}, { 'x-powered-by': 'Nodejitsu' });
+ })
+}).addBatch({
+ 'tokens create test-token': shouldNodejitsuOk(function setup () {
+ nock('http://api.mockjitsu.com')
+ .put('/users/tester/tokens/test-token', {})
+ .reply(201, {"operation":"insert"}, { 'x-powered-by': 'Nodejitsu' });
+ })
+}).addBatch({
+ 'tokens list': shouldNodejitsuOk( function setup () {
+ nock('http://api.mockjitsu.com')
+ .get('/users/tester/tokens')
+ .reply(200, {"apiTokens":{"test-token":"bbe261ea-aa43-4f6d-a3cf-b971301d459b"}}, { 'x-powered-by': 'Nodejitsu' });
+ })
+}).addBatch({
+ 'tokens destroy test-token': shouldNodejitsuOk(function setup () {
+ nock('http://api.mockjitsu.com')
+ .delete('/users/tester/tokens/test-token', {})
+ .reply(201, {"ok":true,"id":"test-token"}, { 'x-powered-by': 'Nodejitsu' });
+ })
+})/*.addBatch({
+ 'tokens create adam': shouldNodejitsuOk(function setup () {
+ nock('http://api.mockjitsu.com')
+ .post('/users/adam/tokens', {})
+ .reply(201, {"operation":"insert"}, { 'x-powered-by': 'Nodejitsu' });
+ })
+})*/.addBatch({
+ 'tokens create adam test-token': shouldNodejitsuOk(function setup () {
+ nock('http://api.mockjitsu.com')
+ .put('/users/adam/tokens/test-token', {})
+ .reply(201, {"operation":"insert"}, { 'x-powered-by': 'Nodejitsu' });
+ })
+}).addBatch({
+ 'tokens list adam': shouldNodejitsuOk( function setup () {
+ nock('http://api.mockjitsu.com')
+ .get('/users/adam/tokens')
+ .reply(200, {"apiTokens":{"test-token":"bbe261ea-aa43-4f6d-a3cf-b971301d459b"}}, { 'x-powered-by': 'Nodejitsu' });
+ })
+}).addBatch({
+ 'tokens destroy adam test-token': shouldNodejitsuOk(function setup () {
+ nock('http://api.mockjitsu.com')
+ .delete('/users/adam/tokens/test-token', {})
+ .reply(201, {"ok":true,"id":"test-token"}, { 'x-powered-by': 'Nodejitsu' });
+ })
+}).export(module);
Please sign in to comment.
Something went wrong with that request. Please try again.