Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

test: add from fs symlinks #421

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions js/src/files-regular/add-from-fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,38 @@ module.exports = (createCommon, options) => {
})
})

it('should add a symlink to a file', (done) => {
const filePath = path.join(fixturesPath, 'symlinks', 'ipfs.txt-link')
ipfs.addFromFs(filePath, (err, files) => {
expect(err).to.not.exist()

const file = files.find(r => r.path === 'ipfs.txt-link')
expect(file).to.exist()

ipfs.cat(file.hash, (err, data) => {
expect(err).to.not.exist()
expect(data.toString()).to.eql('IPFS\n')
done()
})
})
})

it('should add a symlink to a directory', (done) => {
const dirPath = path.join(fixturesPath, 'symlinks', 'real-dir-link')
ipfs.addFromFs(dirPath, { recursive: true }, (err, files) => {
expect(err).to.not.exist()

const file = files.find(r => r.path === 'real-dir-link/real-file.txt')
expect(file).to.exist()

ipfs.cat(file.hash, (err, data) => {
expect(err).to.not.exist()
expect(data.toString()).to.eql('A real file\n')
done()
})
})
})

it('should add a directory from the file system with an odd name', (done) => {
const filesPath = path.join(fixturesPath, 'weird name folder [v0]')
ipfs.addFromFs(filesPath, { recursive: true }, (err, result) => {
Expand Down
1 change: 1 addition & 0 deletions js/test/fixtures/symlinks/ipfs.txt-link
1 change: 1 addition & 0 deletions js/test/fixtures/symlinks/real-dir-link
1 change: 1 addition & 0 deletions js/test/fixtures/symlinks/real-dir/real-file.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
A real file