This repository was archived by the owner on Nov 6, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 82
Remove support for relative path starting with / #148
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
edec182
Remove support for relative path starting with /
pakrym 6cbf0f9
Test
pakrym 677520a
Add negative test
pakrym bd33fc1
Embedded
pakrym f2bcb51
Test fix
pakrym 54c3bda
Test fix
pakrym aa9f3be
whitespace
pakrym 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
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 |
---|---|---|
|
@@ -24,10 +24,15 @@ public void ExistingFilesReturnTrue() | |
var info = provider.GetFileInfo("File.txt"); | ||
Assert.NotNull(info); | ||
Assert.True(info.Exists); | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need a negative test making sure that passing |
||
info = provider.GetFileInfo("/File.txt"); | ||
[Fact] | ||
public void GetFileInfo_FiltersSlashPath() | ||
{ | ||
var provider = new PhysicalFileProvider(Directory.GetCurrentDirectory()); | ||
var info = provider.GetFileInfo("/File.txt"); | ||
Assert.NotNull(info); | ||
Assert.True(info.Exists); | ||
Assert.False(info.Exists); | ||
} | ||
|
||
[Fact] | ||
|
@@ -452,21 +457,33 @@ public void Token_For_Whitespace_Filters() | |
} | ||
} | ||
|
||
[ConditionalFact] | ||
[OSSkipCondition(OperatingSystems.Linux, SkipReason = "Skipping until #104 is resolved.")] | ||
[OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "Skipping until #104 is resolved.")] | ||
[Fact] | ||
public void Token_For_AbsolutePath_Filters() | ||
{ | ||
using (var root = new DisposableFileSystem()) | ||
{ | ||
var provider = new PhysicalFileProvider(root.RootPath); | ||
var path = Path.Combine(root.RootPath, "filename"); | ||
var path = Path.GetFullPath(Path.Combine(root.RootPath, "filename")); | ||
var token = provider.Watch(path); | ||
|
||
Assert.Same(NoopChangeToken.Singleton, token); | ||
} | ||
} | ||
|
||
|
||
[Fact] | ||
public void Token_For_PathStartigWithSlash_Filters() | ||
{ | ||
using (var root = new DisposableFileSystem()) | ||
{ | ||
var provider = new PhysicalFileProvider(root.RootPath); | ||
var path = Path.GetFullPath(Path.Combine(root.RootPath, "")); | ||
var token = provider.Watch("/filename"); | ||
|
||
Assert.Same(NoopChangeToken.Singleton, token); | ||
} | ||
} | ||
|
||
[Fact] | ||
public async Task Token_Fired_For_File_Or_Directory_Create_And_Delete() | ||
{ | ||
|
@@ -519,7 +536,7 @@ public async Task Tokens_With_Path_Ending_With_Slash() | |
string folderName = Guid.NewGuid().ToString(); | ||
|
||
int tokenCount = 0; | ||
var filetoken = provider.Watch("/" + folderName + "/"); | ||
var filetoken = provider.Watch(folderName + "/"); | ||
filetoken.RegisterChangeCallback(_ => { tokenCount++; }, null); | ||
|
||
var folderPath = Path.Combine(root.RootPath, folderName); | ||
|
@@ -529,14 +546,14 @@ public async Task Tokens_With_Path_Ending_With_Slash() | |
await Task.Delay(WaitTimeForTokenToFire); | ||
Assert.Equal(1, tokenCount); | ||
|
||
filetoken = provider.Watch("/" + folderName + "/"); | ||
filetoken = provider.Watch(folderName + "/"); | ||
filetoken.RegisterChangeCallback(_ => { tokenCount++; }, null); | ||
|
||
File.AppendAllText(Path.Combine(folderPath, fileName), "UpdatedContent"); | ||
await Task.Delay(WaitTimeForTokenToFire); | ||
Assert.Equal(2, tokenCount); | ||
|
||
filetoken = provider.Watch("/" + folderName + "/"); | ||
filetoken = provider.Watch(folderName + "/"); | ||
filetoken.RegisterChangeCallback(_ => { tokenCount++; }, null); | ||
|
||
File.Delete(Path.Combine(folderPath, fileName)); | ||
|
@@ -556,15 +573,15 @@ public async Task Tokens_With_Path_Not_Ending_With_Slash() | |
|
||
int tokenCount = 0; | ||
// Matches file/directory with this name. | ||
var filetoken = provider.Watch("/" + directoryName); | ||
var filetoken = provider.Watch(directoryName); | ||
filetoken.RegisterChangeCallback(_ => { tokenCount++; }, null); | ||
|
||
Directory.CreateDirectory(Path.Combine(root.RootPath, directoryName)); | ||
await Task.Delay(WaitTimeForTokenToFire); | ||
Assert.Equal(1, tokenCount); | ||
|
||
// Matches file/directory with this name. | ||
filetoken = provider.Watch("/" + fileName); | ||
filetoken = provider.Watch(fileName); | ||
filetoken.RegisterChangeCallback(_ => { tokenCount++; }, null); | ||
|
||
File.WriteAllText(Path.Combine(root.RootPath, fileName), "Content"); | ||
|
@@ -705,20 +722,16 @@ public void Tokens_With_Forward_And_Backward_Slash() | |
using (var root = new DisposableFileSystem()) | ||
{ | ||
var provider = new PhysicalFileProvider(root.RootPath); | ||
var token1 = provider.Watch("/a/b"); | ||
var token2 = provider.Watch("a/b"); | ||
var token3 = provider.Watch(@"a\b"); | ||
var token1 = provider.Watch("a/b"); | ||
var token2 = provider.Watch(@"a\b"); | ||
|
||
Assert.Equal(token2, token1); | ||
Assert.Equal(token3, token2); | ||
|
||
Assert.True(token1.ActiveChangeCallbacks); | ||
Assert.True(token2.ActiveChangeCallbacks); | ||
Assert.True(token3.ActiveChangeCallbacks); | ||
|
||
Assert.False(token1.HasChanged); | ||
Assert.False(token2.HasChanged); | ||
Assert.False(token3.HasChanged); | ||
} | ||
} | ||
|
||
|
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.
Could you combine this with the condition at Line 94?