-
Notifications
You must be signed in to change notification settings - Fork 99
Fix 108 #109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rianwouters
wants to merge
2
commits into
nodeftpd:master
Choose a base branch
from
rianwouters:fix-108
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Fix 108 #109
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,86 +1,134 @@ | ||
| var common = require('./lib/common'); | ||
| var fs = require('fs'); | ||
|
|
||
| describe('LIST command', function() { | ||
| 'use strict'; | ||
|
|
||
| var client; | ||
| var server; | ||
|
|
||
| beforeEach(function(done) { | ||
| server = common.server(); | ||
| client = common.client(done); | ||
| }); | ||
| describe('regular cases', function() { | ||
|
|
||
| function unslashRgx(rgx) { | ||
| return String(rgx).replace(/^\/|\/$/g, ''); | ||
| } | ||
|
|
||
| it('should return "-" as first character for files', function(done) { | ||
| client.list('/', function(error, listing) { | ||
| error.should.equal(false); | ||
| listing = common.splitResponseLines(listing, / data\d*\.txt$/); | ||
| listing.should.have.lengthOf(6); | ||
| listing[0].should.startWith('-'); | ||
| done(); | ||
| beforeEach(function(done) { | ||
| server = common.server(); | ||
| client = common.client(done); | ||
| }); | ||
| }); | ||
|
|
||
| it('should return "d" as first character for directories', function(done) { | ||
| client.list('/', function(error, listing) { | ||
| error.should.equal(false); | ||
| listing = common.splitResponseLines(listing, / usr$/); | ||
| listing.should.have.lengthOf(1); | ||
| listing[0].should.startWith('d'); | ||
| done(); | ||
| function unslashRgx(rgx) { | ||
| return String(rgx).replace(/^\/|\/$/g, ''); | ||
| } | ||
|
|
||
| it('should return "-" as first character for files', function(done) { | ||
| client.list('/', function(error, listing) { | ||
| error.should.equal(false); | ||
| listing = common.splitResponseLines(listing, / data\d*\.txt$/); | ||
| listing.should.have.lengthOf(6); | ||
| listing[0].should.startWith('-'); | ||
| done(); | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| it('should list files similar to ls -l', function(done) { | ||
| client.list('/usr', function(error, listing) { | ||
| error.should.equal(false); | ||
| listing = common.splitResponseLines(listing); | ||
| listing.should.have.lengthOf(1); | ||
| var lsLongRgx = [ | ||
| /($# file modes: ___|)[d-]([r-][w-][x-]){3}/, | ||
| /($# ?�?�? inodes?: |)\d+/, | ||
| /($# owner name: ___|)\S+/, | ||
| /($# owner group: __|)\S+/, | ||
| /($# size in bytes: |)\d+/, | ||
| /($# month: ________|)[A-Z][a-z]{2}/, | ||
| /($# day of month: _|)\d{1,2}/, | ||
| /($# time or year: _|)([\d ]\d:|19|[2-9]\d)\d{2}/, | ||
| /($# file name: ____|)[\S\s]+/, | ||
| ].map(unslashRgx).join('\\s+'); | ||
| lsLongRgx = new RegExp(lsLongRgx, ''); | ||
| var match = (lsLongRgx.exec(listing[0]) || [false]); | ||
| match[0].should.equal(listing[0]); | ||
| done(); | ||
| it('should return "d" as first character for directories', function(done) { | ||
| client.list('/', function(error, listing) { | ||
| error.should.equal(false); | ||
| listing = common.splitResponseLines(listing, / usr$/); | ||
| listing.should.have.lengthOf(1); | ||
| listing[0].should.startWith('d'); | ||
| done(); | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| it('should list a single file', function(done) { | ||
| var filename = 'data.txt'; | ||
| client.list('/' + filename, function(error, listing) { | ||
| error.should.equal(false); | ||
| listing = common.splitResponseLines(listing, ' ' + filename); | ||
| listing.should.have.lengthOf(1); | ||
| listing[0].should.startWith('-'); | ||
| done(); | ||
| it('should list files similar to ls -l', function(done) { | ||
| client.list('/usr', function(error, listing) { | ||
| error.should.equal(false); | ||
| listing = common.splitResponseLines(listing); | ||
| listing.should.have.lengthOf(1); | ||
| var lsLongRgx = [ | ||
| /($# file modes: ___|)[d-]([r-][w-][x-]){3}/, | ||
| /($# ?�?�? inodes?: |)\d+/, | ||
| /($# owner name: ___|)\S+/, | ||
| /($# owner group: __|)\S+/, | ||
| /($# size in bytes: |)\d+/, | ||
| /($# month: ________|)[A-Z][a-z]{2}/, | ||
| /($# day of month: _|)\d{1,2}/, | ||
| /($# time or year: _|)([\d ]\d:|19|[2-9]\d)\d{2}/, | ||
| /($# file name: ____|)[\S\s]+/, | ||
| ].map(unslashRgx).join('\\s+'); | ||
| lsLongRgx = new RegExp(lsLongRgx, ''); | ||
| var match = (lsLongRgx.exec(listing[0]) || [false]); | ||
| match[0].should.equal(listing[0]); | ||
| done(); | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| it('should list a subdirectory', function(done) { | ||
| client.list('/usr', function(error, listing) { | ||
| error.should.equal(false); | ||
| listing = common.splitResponseLines(listing); | ||
| listing.should.have.lengthOf(1); | ||
| listing[0].should.startWith('d'); | ||
| listing[0].should.endWith(' local'); | ||
| done(); | ||
| it('should list a single file', function(done) { | ||
| var filename = 'data.txt'; | ||
| client.list('/' + filename, function(error, listing) { | ||
| error.should.equal(false); | ||
| listing = common.splitResponseLines(listing, ' ' + filename); | ||
| listing.should.have.lengthOf(1); | ||
| listing[0].should.startWith('-'); | ||
| done(); | ||
| }); | ||
| }); | ||
|
|
||
| it('should list a subdirectory', function(done) { | ||
| client.list('/usr', function(error, listing) { | ||
| error.should.equal(false); | ||
| listing = common.splitResponseLines(listing); | ||
| listing.should.have.lengthOf(1); | ||
| listing[0].should.startWith('d'); | ||
| listing[0].should.endWith(' local'); | ||
| done(); | ||
| }); | ||
| }); | ||
|
|
||
| afterEach(function() { | ||
| server.close(); | ||
| }); | ||
| }); | ||
|
|
||
| afterEach(function() { | ||
| server.close(); | ||
| describe('corner cases', function() { | ||
| 'use strict'; | ||
|
|
||
| var files; | ||
|
|
||
| beforeEach(function(done) { | ||
| server = common.server({ | ||
| fs: { | ||
| stat: function(path, callback) { | ||
| console.log('STAT', path); | ||
| callback( | ||
| undefined /* err */, | ||
| new fs.Stats(0,32768 /* file mode */,0,0,0,0,0,0,0,43 /* size */,0,0,0,0) | ||
| ); | ||
| }, | ||
| readdir: function(path, callback) { | ||
| console.log('READDIR', path); | ||
| callback(undefined, files); | ||
| }, | ||
| }, | ||
| }); | ||
| client = common.client(done); | ||
| }); | ||
|
|
||
|
|
||
| it.only('supports directories with only a few files', function(done) { | ||
| files = ['a']; | ||
| client.list('/', function(error, listing) { | ||
| error.should.equal(false); | ||
| console.log(listing); | ||
| listing = common.splitResponseLines(listing); | ||
| listing.should.have.lengthOf(1); | ||
| done(); | ||
| }); | ||
| }); | ||
|
|
||
| afterEach(function() { | ||
| server.close(); | ||
| }); | ||
| }); | ||
|
|
||
|
|
||
| }); | ||
|
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd consider a comparison with
Math.min()more readable. Fans of premature optimization could save themin()result in a variable. ;-)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine with me as long as its also done at the other places where this construction is used.
Anyhow it will change as the CONC construction is not working properly anyway for synchronous implementations . :-)
Verzonden van mijn HTC
----- Reply message -----
Van: "M.K." [email protected]
Aan: "sstur/nodeftpd" [email protected]
CC: "rianwouters" [email protected], "Author" [email protected]
Onderwerp: [sstur/nodeftpd] Fix 108 (#109)
Datum: vr, jun. 17, 2016 13:08
I'd consider a comparison with
Math.min()more readable. Fans of premature optimization could save themin()result in a variable. ;-)You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub:
https://github.com/sstur/nodeftpd/pull/109/files/f90a4004d3b42385edd37998b8a8f178389914d4#r67494604