mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-17 01:25:40 -05:00
- 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:
@@ -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()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user