mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-17 02:51:45 -05:00
Fix handling some SQL Assessment warnings (#1114)
* Some new SQL Assessment warnings may have Check property set to null. Handle the warnings with no exception. * Make names of SQL Assessment test methods more informative.
This commit is contained in:
@@ -384,14 +384,14 @@ namespace Microsoft.SqlTools.ServiceLayer.SqlAssessment
|
|||||||
{
|
{
|
||||||
var item = new AssessmentResultItem
|
var item = new AssessmentResultItem
|
||||||
{
|
{
|
||||||
CheckId = r.Check.Id,
|
CheckId = r.Check?.Id ?? string.Empty,
|
||||||
Description = r.Check.Description,
|
Description = r.Check?.Description ?? string.Empty,
|
||||||
DisplayName = r.Check.DisplayName,
|
DisplayName = r.Check?.DisplayName ?? string.Empty,
|
||||||
HelpLink = r.Check.HelpLink,
|
HelpLink = r.Check?.HelpLink ?? string.Empty,
|
||||||
Level = r.Check.Level.ToString(),
|
Level = r.Check?.Level.ToString() ?? string.Empty,
|
||||||
Message = r.Message,
|
Message = r.Message,
|
||||||
TargetName = r.TargetPath,
|
TargetName = r.TargetPath,
|
||||||
Tags = r.Check.Tags.ToArray(),
|
Tags = r.Check?.Tags.ToArray() ?? Array.Empty<string>(),
|
||||||
TargetType = r.TargetType,
|
TargetType = r.TargetType,
|
||||||
RulesetVersion = Engine.Configuration.DefaultRuleset.Version.ToString(),
|
RulesetVersion = Engine.Configuration.DefaultRuleset.Version.ToString(),
|
||||||
RulesetName = Engine.Configuration.DefaultRuleset.Name,
|
RulesetName = Engine.Configuration.DefaultRuleset.Name,
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.SqlAssessment
|
|||||||
{
|
{
|
||||||
private delegate Task<List<TResult>> AssessmentMethod<TResult>(SqlObjectLocator locator);
|
private delegate Task<List<TResult>> AssessmentMethod<TResult>(SqlObjectLocator locator);
|
||||||
|
|
||||||
private static readonly string[] AllowedSeverityLevels = { "Information", "Warning", "Critical" };
|
private static readonly string[] AllowedSeverityLevels = { string.Empty, "Information", "Warning", "Critical" };
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public async Task InvokeSqlAssessmentServerTest()
|
public async Task InvokeSqlAssessmentServerTest()
|
||||||
@@ -56,7 +56,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.SqlAssessment
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public async Task GetAssessmentItemsServerTest()
|
public async Task GetSqlAssessmentItemsServerTest()
|
||||||
{
|
{
|
||||||
var liveConnection = LiveConnectionHelper.InitLiveConnectionInfo("master");
|
var liveConnection = LiveConnectionHelper.InitLiveConnectionInfo("master");
|
||||||
|
|
||||||
@@ -81,7 +81,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.SqlAssessment
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public async Task GetAssessmentItemsDatabaseTest()
|
public async Task GetSqlAssessmentItemsDatabaseTest()
|
||||||
{
|
{
|
||||||
const string DatabaseName = "tempdb";
|
const string DatabaseName = "tempdb";
|
||||||
var liveConnection = LiveConnectionHelper.InitLiveConnectionInfo(DatabaseName);
|
var liveConnection = LiveConnectionHelper.InitLiveConnectionInfo(DatabaseName);
|
||||||
@@ -214,9 +214,9 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.SqlAssessment
|
|||||||
{
|
{
|
||||||
Assert.Multiple(() =>
|
Assert.Multiple(() =>
|
||||||
{
|
{
|
||||||
Assert.That(item.CheckId, Is.Not.Null.Or.Empty);
|
Assert.That(item.CheckId, Is.Not.Null);
|
||||||
Assert.That(item.DisplayName, Is.Not.Null.Or.Empty);
|
Assert.That(item.DisplayName, Is.Not.Null);
|
||||||
Assert.That(item.Description, Is.Not.Null.Or.Empty);
|
Assert.That(item.Description, Is.Not.Null);
|
||||||
Assert.NotNull(item.Tags);
|
Assert.NotNull(item.Tags);
|
||||||
Assert.That(item.Tags, Has.All.Not.Null.Or.Empty);
|
Assert.That(item.Tags, Has.All.Not.Null.Or.Empty);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -126,14 +126,14 @@ INSERT INTO [dbo].[AssessmentResult] ([CheckName],[CheckId],[RulesetName],[Rules
|
|||||||
) rpt([CheckName],[CheckId],[RulesetName],[RulesetVersion],[Severity],[Message],[TargetPath],[TargetType],[HelpLink],[Timestamp])";
|
) rpt([CheckName],[CheckId],[RulesetName],[RulesetVersion],[Severity],[Message],[TargetPath],[TargetType],[HelpLink],[Timestamp])";
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void GenerateScriptTest()
|
public void GenerateSqlAssessmentScriptTest()
|
||||||
{
|
{
|
||||||
var scriptText = GenerateScriptOperation.GenerateScript(SampleParams, CancellationToken.None);
|
var scriptText = GenerateScriptOperation.GenerateScript(SampleParams, CancellationToken.None);
|
||||||
Assert.AreEqual(SampleScript, scriptText);
|
Assert.AreEqual(SampleScript, scriptText);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void ExecuteTest()
|
public void ExecuteSqlAssessmentScriptTest()
|
||||||
{
|
{
|
||||||
var subject = new GenerateScriptOperation(SampleParams);
|
var subject = new GenerateScriptOperation(SampleParams);
|
||||||
var taskMetadata = new TaskMetadata();
|
var taskMetadata = new TaskMetadata();
|
||||||
|
|||||||
Reference in New Issue
Block a user