Browse Source

update tests

ameba23 3 years ago
parent
commit
afb9275bd3
1 changed files with 13 additions and 13 deletions
  1. 13
    13
      test/index.test.js

+ 13
- 13
test/index.test.js View File

@@ -1,7 +1,7 @@
1 1
 const { describe } = require('tape-plus')
2 2
 const ram = require('random-access-memory')
3 3
 const fs = require('fs')
4
-const Mount = require('../')
4
+const mount = require('../')
5 5
 const KappaDrive = require('kappa-drive')
6 6
 const path = require('path')
7 7
 
@@ -11,7 +11,6 @@ const { replicate, tmp, run } = require('./util')
11 11
 
12 12
 describe('mount', (context) => {
13 13
   context('read mounted directory', (assert, next) => {
14
-    var mount = Mount()
15 14
     var drive = KappaDrive(ram)
16 15
     var storage = tmp()
17 16
 
@@ -19,6 +18,7 @@ describe('mount', (context) => {
19 18
       drive.writeFile('/hello.txt', 'world', (err) => {
20 19
         assert.error(err, 'no error')
21 20
         mount(drive, storage, (err, unmount) => {
21
+          assert.error(err, 'no error when mounting')
22 22
           fs.readdir(storage, (err, files) => {
23 23
             assert.error(err, 'no error')
24 24
             assert.same(files, ['hello.txt'], 'readdir returns the written file')
@@ -34,12 +34,12 @@ describe('mount', (context) => {
34 34
   })
35 35
 
36 36
   context('write to mounted directory', (assert, next) => {
37
-    var mount = Mount()
38 37
     var drive = KappaDrive(ram)
39 38
     var storage = tmp()
40 39
 
41 40
     drive.ready(() => {
42 41
       mount(drive, storage, (err, unmount) => {
42
+        assert.error(err, 'no error when mounting')
43 43
         fs.writeFile(path.join(storage, 'hello.txt'), 'world', (err) => {
44 44
           assert.error(err, 'no error')
45 45
           drive.readdir('/', (err, files) => {
@@ -53,11 +53,11 @@ describe('mount', (context) => {
53 53
   })
54 54
 
55 55
   context('mkdir in mounted directory', (assert, next) => {
56
-    var mount = Mount()
57 56
     var drive = KappaDrive(ram)
58 57
     var storage = tmp()
59 58
     drive.ready(() => {
60 59
       mount(drive, storage, (err, unmount) => {
60
+        assert.error(err, 'no error when mounting')
61 61
         fs.mkdir(path.join(storage, 'antelopes'), (err) => {
62 62
           assert.error(err, 'no error')
63 63
           drive.readdir('/', (err, files) => {
@@ -71,11 +71,11 @@ describe('mount', (context) => {
71 71
   })
72 72
 
73 73
   context('readdir in mounted newly created directory', (assert, next) => {
74
-    var mount = Mount()
75 74
     var drive = KappaDrive(ram)
76 75
     var storage = tmp()
77 76
     drive.ready(() => {
78 77
       mount(drive, storage, (err, unmount) => {
78
+        assert.error(err, 'no error when mounting')
79 79
         fs.mkdir(path.join(storage, 'antelopes'), (err) => {
80 80
           assert.error(err, 'no error')
81 81
           fs.readdir(path.join(storage, 'antelopes'), (err, files) => {
@@ -96,11 +96,11 @@ describe('mount', (context) => {
96 96
   })
97 97
 
98 98
   context('unlink in mounted directory', (assert, next) => {
99
-    var mount = Mount()
100 99
     var drive = KappaDrive(tmp())
101 100
     var storage = tmp()
102 101
     drive.ready(() => {
103 102
       mount(drive, storage, (err, unmount) => {
103
+        assert.error(err, 'no error when mounting')
104 104
         fs.writeFile(path.join(storage, 'tree.txt'), 'is this a tree', (err) => {
105 105
           assert.error(err, 'no error')
106 106
           fs.readdir(storage, (err, files) => {
@@ -127,7 +127,6 @@ describe('mount', (context) => {
127 127
     }
128 128
     var orangeDrive = KappaDrive(feedsOnDisk.orange)
129 129
     var blueDrive = KappaDrive(feedsOnDisk.blue)
130
-    var mount = Mount()
131 130
 
132 131
     var storage = {}
133 132
     var unmount = {}
@@ -135,6 +134,7 @@ describe('mount', (context) => {
135 134
     function setup (drive, colour, cb) {
136 135
       storage[colour] = tmp()
137 136
       mount(drive, storage[colour], (err, unmountFn) => {
137
+        assert.error(err, 'no error when mounting')
138 138
         unmount[colour] = unmountFn
139 139
         drive.ready(cb)
140 140
       })
@@ -168,7 +168,6 @@ describe('mount', (context) => {
168 168
     }
169 169
     var orangeDrive = KappaDrive(feedsOnDisk.orange)
170 170
     var blueDrive = KappaDrive(feedsOnDisk.blue)
171
-    var mount = Mount()
172 171
 
173 172
     var storage = {}
174 173
     var unmount = {}
@@ -176,6 +175,7 @@ describe('mount', (context) => {
176 175
     function setup (drive, colour, cb) {
177 176
       storage[colour] = tmp()
178 177
       mount(drive, storage[colour], (err, unmountFn) => {
178
+        assert.error(err, 'no error when mounting')
179 179
         unmount[colour] = unmountFn
180 180
         drive.ready(cb)
181 181
       })
@@ -228,7 +228,6 @@ describe('mount', (context) => {
228 228
     }
229 229
     var orangeDrive = KappaDrive(feedsOnDisk.orange)
230 230
     var blueDrive = KappaDrive(feedsOnDisk.blue)
231
-    var mount = Mount()
232 231
 
233 232
     var storage = {}
234 233
     var unmount = {}
@@ -236,6 +235,7 @@ describe('mount', (context) => {
236 235
     function setup (drive, colour, cb) {
237 236
       storage[colour] = tmp()
238 237
       mount(drive, storage[colour], (err, unmountFn) => {
238
+        assert.error(err, 'no error when mounting')
239 239
         unmount[colour] = unmountFn
240 240
         drive.ready(cb)
241 241
       })
@@ -288,7 +288,6 @@ describe('mount', (context) => {
288 288
     }
289 289
     var orangeDrive = KappaDrive(feedsOnDisk.orange)
290 290
     var blueDrive = KappaDrive(feedsOnDisk.blue)
291
-    var mount = Mount()
292 291
 
293 292
     var storage = {}
294 293
     var unmount = {}
@@ -296,6 +295,7 @@ describe('mount', (context) => {
296 295
     function setup (drive, colour, cb) {
297 296
       storage[colour] = tmp()
298 297
       mount(drive, storage[colour], (err, unmountFn) => {
298
+        assert.error(err, 'no error when mounting')
299 299
         unmount[colour] = unmountFn
300 300
         drive.ready(cb)
301 301
       })
@@ -348,7 +348,6 @@ describe('mount', (context) => {
348 348
 
349 349
     var orangeDrive = KappaDrive(feedsOnDisk.orange)
350 350
     var blueDrive = KappaDrive(feedsOnDisk.blue)
351
-    var mount = Mount()
352 351
 
353 352
     var storage = {}
354 353
     var unmount = {}
@@ -356,6 +355,7 @@ describe('mount', (context) => {
356 355
     function setup (drive, colour, cb) {
357 356
       storage[colour] = tmp()
358 357
       mount(drive, storage[colour], (err, unmountFn) => {
358
+        assert.error(err, 'no error when mounting')
359 359
         unmount[colour] = unmountFn
360 360
         drive.ready(cb)
361 361
       })
@@ -400,7 +400,6 @@ describe('mount', (context) => {
400 400
     }
401 401
     var orangeDrive = KappaDrive(feedsOnDisk.orange)
402 402
     var blueDrive = KappaDrive(feedsOnDisk.blue)
403
-    var mount = Mount()
404 403
 
405 404
     var storage = {}
406 405
     var unmount = {}
@@ -408,6 +407,7 @@ describe('mount', (context) => {
408 407
     function setup (drive, colour, cb) {
409 408
       storage[colour] = tmp()
410 409
       mount(drive, storage[colour], (err, unmountFn) => {
410
+        assert.error(err, 'no error when mounting')
411 411
         unmount[colour] = unmountFn
412 412
         drive.ready(cb)
413 413
       })
@@ -461,7 +461,6 @@ describe('mount', (context) => {
461 461
 
462 462
     var yellowDrive = KappaDrive(feedsOnDisk.yellow)
463 463
     var purpleDrive = KappaDrive(feedsOnDisk.purple)
464
-    var mount = Mount()
465 464
 
466 465
     var storage = {}
467 466
     var unmount = {}
@@ -469,6 +468,7 @@ describe('mount', (context) => {
469 468
     function setup (drive, colour, cb) {
470 469
       storage[colour] = tmp()
471 470
       mount(drive, storage[colour], (err, unmountFn) => {
471
+        assert.error(err, 'no error when mounting')
472 472
         unmount[colour] = unmountFn
473 473
         drive.ready(cb)
474 474
       })