Fix #911 handle perforce files (#400)

- Additional handling of document events with "perforce:" or other SCM strings
- Much of the handling had been added already, but adding in additional validation and ensuring that everywhere `Workspace.GetFile` is called we add a not-null check to avoid null reference errors
This commit is contained in:
Kevin Cunnane
2017-07-05 13:25:05 -07:00
committed by GitHub
parent 2a5ae06f12
commit 3aba287759
16 changed files with 152 additions and 40 deletions

View File

@@ -149,12 +149,22 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Workspace
[Fact]
public async Task DontProcessGitFileEvents()
{
// setup test workspace
await VerifyFileIsNotAddedOnDocOpened("git:/myfile.sql");
}
[Fact]
public async Task DontProcessPerforceFileEvents()
{
await VerifyFileIsNotAddedOnDocOpened("perforce:/myfile.sql");
}
private async Task VerifyFileIsNotAddedOnDocOpened(string filePath)
{
// setup test workspace
var workspace = new ServiceLayer.Workspace.Workspace();
var workspaceService = new WorkspaceService<SqlToolsSettings> {Workspace = workspace};
// send a document open event with git:/ prefix URI
string filePath = "git:/myfile.sql";
var openParams = new DidOpenTextDocumentNotification
{
TextDocument = new TextDocumentItem { Uri = filePath }
@@ -178,6 +188,15 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Workspace
Assert.False(workspaceService.Workspace.ContainsFile(filePath));
}
[Fact]
public void GetFileReturnsNullForPerforceFile()
{
// when I ask for a non-file object in the workspace, it should return null
var workspace = new ServiceLayer.Workspace.Workspace();
ScriptFile file = workspace.GetFile("perforce:myfile.sql");
Assert.Null(file);
}
[Fact]
public async Task WorkspaceContainsFile()
{