Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin Cui <[email protected]>
  • Loading branch information
BlackHole1 committed Mar 28, 2024
1 parent d278f71 commit 880d020
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
32 changes: 29 additions & 3 deletions test/filesystem-spec.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,42 @@
'use strict'

const assert = require('assert')
const fs = require('../lib/wrapped-fs')
const path = require('path')
const rimraf = require('rimraf')

const Filesystem = require('../lib/filesystem')

describe('filesystem', function () {
beforeEach(() => { rimraf.sync(path.join(__dirname, '..', 'tmp'), fs) })

it('should does not throw error when src path include symbol link', async () => {
const src = path.join(__dirname, 'input', 'srcpath-include-symlink', 'var', 'app')
const filesystem = new Filesystem(src)
/* eslint-disable no-irregular-whitespace */
/**
* Directory structure:
* tmp
* ├── private
* │   └── var
* │   ├── app
* │   │   └── file.txt -> ../file.txt
* │   └── file.txt
* └── var -> private/var
*/
const tmpPath = path.join(__dirname, '..', 'tmp')
const privateVarPath = path.join(tmpPath, 'private', 'var')
const varPath = path.join(tmpPath, 'var')
fs.mkdirSync(privateVarPath, { recursive: true })
fs.symlinkSync(path.relative(tmpPath, privateVarPath), varPath)

const originFilePath = path.join(varPath, 'file.txt')
fs.writeFileSync(originFilePath, 'hello world')
const appPath = path.join(varPath, 'app')
fs.mkdirpSync(appPath)
fs.symlinkSync('../file.txt', path.join(appPath, 'file.txt'))

const filesystem = new Filesystem(varPath)
assert.doesNotThrow(() => {
filesystem.insertLink(path.join(src, 'symbol', 'real.txt'))
filesystem.insertLink(path.join(appPath, 'file.txt'))
})
})
})
Empty file.

This file was deleted.

1 change: 0 additions & 1 deletion test/input/srcpath-include-symlink/var

This file was deleted.

0 comments on commit 880d020

Please sign in to comment.