Skip to content
This repository
Browse code

[test] Test for apps without specified appname

  • Loading branch information...
commit 40be33ce5b8c2bb2d6269933078eead62aa5aadf 1 parent 4ae4d64
Joshua Holbrook authored February 23, 2012

Showing 1 changed file with 59 additions and 72 deletions. Show diff stats Hide diff stats

  1. 131  test/commands/apps-test.js
131  test/commands/apps-test.js
@@ -13,7 +13,10 @@ var assert = require('assert'),
13 13
     jitsu = require('../../lib/jitsu'),
14 14
     macros = require('../helpers/macros');
15 15
 
16  
-var shouldNodejitsuOk = macros.shouldNodejitsuOk;
  16
+var shouldNodejitsuOk = macros.shouldNodejitsuOk,
  17
+    useAppFixture = macros.useAppFixture;
  18
+
  19
+var mainDirectory = process.cwd();
17 20
 
18 21
 vows.describe('jitsu/commands/apps').addBatch({
19 22
   'apps list': shouldNodejitsuOk(function setup() {
@@ -58,81 +61,65 @@ vows.describe('jitsu/commands/apps').addBatch({
58 61
     nock('http://api.mockjitsu.com')
59 62
       .post('/apps/tester/application3/stop', {})
60 63
         .reply(200, '', { 'x-powered-by': 'Nodejitsu' })
61  
-      .get('/apps/micke/application3')
  64
+      .get('/apps/tester/application3')
62 65
       .reply(200, {
63 66
           app: { state: 'stopped' }
64 67
       }, { 'x-powered-by': 'Nodejitsu' })
65 68
   })
66  
-})/*.addBatch({
67  
-  'apps deploy': runJitsuCommand(
68  
-    function setup () {
69  
-      var packageFile = path.join(__dirname, '..', 'fixtures', 'example-app', 'package.json');
70  
-      var pkg = {
71  
-        name: 'example-app',
72  
-        subdomain: 'example-app',
73  
-        scripts: { start: 'server.js' },
74  
-        version: '0.0.0'
75  
-      };
  69
+})
  70
+.addBatch({
  71
+  'apps view': shouldNodejitsuOk(function setup() {
76 72
 
77  
-      fs.writeFileSync(packageFile, JSON.stringify(pkg))
78  
-      process.chdir(path.join(__dirname, '..', 'fixtures', 'example-app'));
79  
-    },
80  
-    mockPrompt2({answer: 'yes'}),
81  
-    mockRequest.mock(helper.mockOptions, helper.mockDefaults)
82  
-      .get('/apps/mickey/example-app')
83  
-      .respond({
84  
-        body: {
85  
-          app: {
86  
-            name: 'example-app', 
87  
-            state: 'stopped', 
88  
-            subdomain:'example-app', 
89  
-            scripts: { start: './server.js' }, 
90  
-            snapshots: [{ filename: 'FILENAME' }] 
91  
-          }
92  
-        }
93  
-      })
94  
-      .post('/apps/mickey/example-app/snapshots/0.0.0-1',null,{'Content-Type' : 'application/octet-stream'})
95  
-      .put('/apps/mickey/example-app')
96  
-      .respond({
97  
-        body: {
98  
-          app: { state: 'stopped' }
99  
-        }
100  
-      })
101  
-      .post('/apps/mickey/example-app/snapshots/0.0.0-1/activate')
102  
-      .post('/apps/mickey/example-app/stop')
103  
-      .post('/apps/mickey/example-app/start')
104  
-      .get('/apps/mickey/example-app')
105  
-      .respond({
106  
-        body: {
107  
-          app: { 
108  
-            name: 'example-app',
109  
-            subdomain: 'example-app',
110  
-            scripts: { start: 'server.js' },
111  
-            version: '0.0.0'
112  
-          }
  73
+    useAppFixture();
  74
+
  75
+    nock('http://api.mockjitsu.com')
  76
+      .get('/apps/tester/example-app')
  77
+      .reply(200, {
  78
+        app: { 
  79
+          name: 'application', 
  80
+          state: 'stopped', 
  81
+          subdomain:'application', 
  82
+          scripts: { start: './server.js' }, 
  83
+          snapshots: [{ filename: 'FILENAME' }] 
113 84
         }
114  
-      })
115  
-    )
116  
-})*/.export(module);
  85
+      }, { 'x-powered-by': 'Nodejitsu' })
  86
+  }, function assertion (err) {
  87
+    process.chdir(mainDirectory);
  88
+    console.error(err);
  89
+    assert.ok(!err);
  90
+  })
  91
+}).addBatch({
  92
+  'apps start': shouldNodejitsuOk(function setup() {
117 93
 
118  
-/*exports ['jitsu apps create'] = makeCommandTest(
119  
-    ['apps','create', 'application3'],//command
120  
-    mockPrompt(jitsu.package.properties(__dirname), {}),//no prompt //an auth is requested only once.
121  
-    [ [ { method:'POST', //post request to start app
122  
-          uri:'http://api.mockjitsu.com:90210/apps/mickey/application3/stop',
123  
-          headers:{ 'Content-Type':"application/json" },
124  
-          //body: '{}' //not really necessary to send the body.
125  
-        },
126  
-        {  }, // one snapshot
127  
-        200 ],
128  
-      [ { method:'GET', //get request to view app status.
129  
-          uri:'http://api.mockjitsu.com:90210/apps/mickey/application3',
130  
-          headers:{ 'Content-Type':"application/json" },
131  
-          //body: '{}' //not really necessary to send the body.
132  
-        },
133  
-        { app: //response body
134  
-          { state: 'stopped' } },
135  
-        200 ]
136  
-    ],
137  
-    assert.ifError )
138  
-*/
  94
+    useAppFixture();
  95
+
  96
+    nock('http://api.mockjitsu.com')
  97
+      .post('/apps/tester/example-app/start', {})
  98
+        .reply(200, '', { 'x-powered-by': 'Nodejitsu' })
  99
+      .get('/apps/tester/example-app')
  100
+        .reply(200, {
  101
+          app: { state: 'started' }
  102
+        }, { 'x-powered-by': 'Nodejitsu' })
  103
+  }, function assertion (err) {
  104
+    process.chdir(mainDirectory);
  105
+    console.error(err);
  106
+    assert.ok(!err);
  107
+  })
  108
+}).addBatch({
  109
+  'apps stop': shouldNodejitsuOk(function setup() {
  110
+
  111
+    useAppFixture();
  112
+
  113
+    nock('http://api.mockjitsu.com')
  114
+      .post('/apps/tester/example-app/stop', {})
  115
+        .reply(200, '', { 'x-powered-by': 'Nodejitsu' })
  116
+      .get('/apps/tester/example-app')
  117
+      .reply(200, {
  118
+          app: { state: 'stopped' }
  119
+      }, { 'x-powered-by': 'Nodejitsu' })
  120
+  }, function assertion (err) {
  121
+    process.chdir(mainDirectory);
  122
+    console.error(err);
  123
+    assert.ok(!err);
  124
+  })
  125
+}).export(module);

0 notes on commit 40be33c

Please sign in to comment.
Something went wrong with that request. Please try again.