1
0
mirror of https://github.com/fuse-friends/fuse-native synced 2026-03-02 03:40:15 +00:00

all tests pass except clean unmounting

This commit is contained in:
Andrew Osheroff
2019-08-02 00:19:00 +02:00
parent 1be624229f
commit 54a5d6c0b3
5 changed files with 36 additions and 30 deletions

View File

@@ -1,16 +1,17 @@
var mnt = require('./fixtures/mnt')
var stat = require('./fixtures/stat')
var fuse = require('../')
var tape = require('tape')
var fs = require('fs')
var path = require('path')
const tape = require('tape')
const fs = require('fs')
const path = require('path')
const Fuse = require('../')
const mnt = require('./fixtures/mnt')
const stat = require('./fixtures/stat')
tape('readlink', function (t) {
var ops = {
force: true,
readdir: function (path, cb) {
if (path === '/') return cb(null, ['hello', 'link'])
return cb(fuse.ENOENT)
return cb(Fuse.ENOENT)
},
readlink: function (path, cb) {
cb(0, 'hello')
@@ -19,7 +20,7 @@ tape('readlink', function (t) {
if (path === '/') return cb(null, stat({ mode: 'dir', size: 4096 }))
if (path === '/hello') return cb(null, stat({ mode: 'file', size: 11 }))
if (path === '/link') return cb(null, stat({ mode: 'link', size: 5 }))
return cb(fuse.ENOENT)
return cb(Fuse.ENOENT)
},
open: function (path, flags, cb) {
cb(0, 42)
@@ -32,7 +33,8 @@ tape('readlink', function (t) {
}
}
fuse.mount(mnt, ops, function (err) {
const fuse = new Fuse(mnt, ops, { debug: true })
fuse.mount(function (err) {
t.error(err, 'no error')
fs.lstat(path.join(mnt, 'link'), function (err, stat) {
@@ -51,7 +53,7 @@ tape('readlink', function (t) {
t.error(err, 'no error')
t.same(buf, new Buffer('hello world'), 'can read link content')
fuse.unmount(mnt, function () {
fuse.unmount( function () {
t.end()
})
})

View File

@@ -12,17 +12,18 @@ tape('read', function (t) {
force: true,
readdir: function (path, cb) {
if (path === '/') return cb(null, ['test'])
return cb(fuse.ENOENT)
return cb(Fuse.ENOENT)
},
getattr: function (path, cb) {
if (path === '/') return cb(null, stat({ mode: 'dir', size: 4096 }))
if (path === '/test') return cb(null, stat({ mode: 'file', size: 11 }))
return cb(fuse.ENOENT)
return cb(Fuse.ENOENT)
},
open: function (path, flags, cb) {
cb(0, 42)
},
release: function (path, fd, cb) {
t.same(fd, 42, 'fd was passed to release')
cb(0)
},
@@ -35,7 +36,6 @@ tape('read', function (t) {
}
const fuse = new Fuse(mnt, ops, { debug: true })
fuse.mount(function (err) {
t.error(err, 'no error')
@@ -53,7 +53,7 @@ tape('read', function (t) {
fs.createReadStream(path.join(mnt, 'test'), { start: 6, end: 10 }).pipe(concat(function (buf) {
t.same(buf, new Buffer('world'), 'partial read file + start offset')
fuse.unmount(mnt, function () {
fuse.unmount(function () {
t.end()
})
}))

View File

@@ -1,9 +1,10 @@
var mnt = require('./fixtures/mnt')
var stat = require('./fixtures/stat')
var fuse = require('../')
var tape = require('tape')
var fs = require('fs')
var path = require('path')
const tape = require('tape')
const fs = require('fs')
const path = require('path')
const Fuse = require('../')
const mnt = require('./fixtures/mnt')
const stat = require('./fixtures/stat')
tape('write', function (t) {
var created = false
@@ -14,15 +15,15 @@ tape('write', function (t) {
force: true,
readdir: function (path, cb) {
if (path === '/') return cb(null, created ? ['hello'] : [])
return cb(fuse.ENOENT)
return cb(Fuse.ENOENT)
},
truncate: function (path, size, cb) {
cb(0)
},
getattr: function (path, cb) {
if (path === '/') return cb(null, stat({ mode: 'dir', size: 4096 }))
if (path === '/hello' && created) return cb(null, stat({ mode: 'file', size: size }))
return cb(fuse.ENOENT)
if (path === '/hello' && created) return cb(0, stat({ mode: 'file', size: size }))
return cb(Fuse.ENOENT)
},
create: function (path, flags, cb) {
t.ok(!created, 'file not created yet')
@@ -39,14 +40,15 @@ tape('write', function (t) {
}
}
fuse.mount(mnt, ops, function (err) {
const fuse = new Fuse(mnt, ops, { debug: true })
fuse.mount(function (err) {
t.error(err, 'no error')
fs.writeFile(path.join(mnt, 'hello'), 'hello world', function (err) {
t.error(err, 'no error')
t.same(data.slice(0, size), new Buffer('hello world'), 'data was written')
fuse.unmount(mnt, function () {
fuse.unmount(function () {
t.end()
})
})