diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 068893fb..493eb2ac 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -17,7 +17,7 @@ jobs: - name: Build project run: dotnet build - name: Run unit tests - run: dotnet test --logger "console;verbosity=detailed" + run: dotnet test --logger "console;verbosity=detailed" -graphBuild:True - name: Code Coverage Report uses: irongut/CodeCoverageSummary@v1.3.0 with: diff --git a/Core/Cosmos.DataTransfer.Core.UnitTests/SettingsCommandTests.cs b/Core/Cosmos.DataTransfer.Core.UnitTests/SettingsCommandTests.cs index b3b48927..8fe62aef 100644 --- a/Core/Cosmos.DataTransfer.Core.UnitTests/SettingsCommandTests.cs +++ b/Core/Cosmos.DataTransfer.Core.UnitTests/SettingsCommandTests.cs @@ -17,6 +17,8 @@ namespace Cosmos.DataTransfer.Core.UnitTests [TestClass] public class SettingsCommandTests { + // TODO: What is the purpose of this test? + // It seems to be a very elaborate method to assert parsing null. [TestMethod] public void Invoke_ForTestExtension_ProducesValidSettingsJson() { @@ -65,8 +67,10 @@ public void Invoke_ForTestExtension_ProducesValidSettingsJson() WriteIndented = true }; var fullJson = stringBuilder.ToString().Trim(); + Assert.AreEqual("null", fullJson); var parsed = JsonSerializer.Deserialize>(fullJson, options); - var parsedJson = JsonSerializer.Serialize>(parsed, options); + Assert.IsNull(parsed); + var parsedJson = JsonSerializer.Serialize>(parsed!, options); Assert.AreEqual(fullJson, parsedJson); } diff --git a/Extensions/PostgreSQL/PostgreDataCol.cs b/Extensions/PostgreSQL/PostgreDataCol.cs index 9cf23ff3..080fe7b7 100644 --- a/Extensions/PostgreSQL/PostgreDataCol.cs +++ b/Extensions/PostgreSQL/PostgreDataCol.cs @@ -35,8 +35,11 @@ public PostgreDataCol(string colname, string postgredatatye) ColumnType = Convert(PostgreType); } - public PostgreDataCol() + public PostgreDataCol(string colname, Type coltype, NpgsqlTypes.NpgsqlDbType postgredatatye) { + ColumnName = colname; + PostgreType = postgredatatye; + ColumnType = coltype; } public Dictionary SparseColumnData { get; } = new Dictionary(); diff --git a/Extensions/PostgreSQL/PostgresqlDataSinkExtension.cs b/Extensions/PostgreSQL/PostgresqlDataSinkExtension.cs index 8f16dce2..397fcd80 100644 --- a/Extensions/PostgreSQL/PostgresqlDataSinkExtension.cs +++ b/Extensions/PostgreSQL/PostgresqlDataSinkExtension.cs @@ -86,7 +86,7 @@ private async Task> FindPostgreDataTypes(IAsyncEnumerable MapDataTypes(List dest, List LoadTableSchema(NpgsqlConnection con, string { if (row != null) { - var newcol = new PostgreDataCol(row["column_name"]?.ToString(), row["udt_name"]?.ToString()); + var newcol = new PostgreDataCol(row["column_name"]?.ToString()!, row["udt_name"]?.ToString()!); temp.Add(newcol); } } diff --git a/Extensions/PostgreSQL/Settings/PostgreSinkSettings.cs b/Extensions/PostgreSQL/Settings/PostgreSinkSettings.cs index 3ab0bde4..4f9aef42 100644 --- a/Extensions/PostgreSQL/Settings/PostgreSinkSettings.cs +++ b/Extensions/PostgreSQL/Settings/PostgreSinkSettings.cs @@ -6,7 +6,9 @@ namespace Cosmos.DataTransfer.PostgresqlExtension.Settings public class PostgreSinkSettings : PostgreBaseSettings { [Required] +#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable. public string TableName { get; set; } +#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable. public bool? AppendDataToTable { get; set; } public bool? DropAndCreateTable { get; set; } diff --git a/Extensions/PostgreSQL/Settings/PostgreSourceSettings.cs b/Extensions/PostgreSQL/Settings/PostgreSourceSettings.cs index 96549f3d..b73028bb 100644 --- a/Extensions/PostgreSQL/Settings/PostgreSourceSettings.cs +++ b/Extensions/PostgreSQL/Settings/PostgreSourceSettings.cs @@ -7,7 +7,7 @@ public class PostgreSourceSettings:PostgreBaseSettings { [Required] [SensitiveValue] - public string? ConnectionString { get; set; } + public new string? ConnectionString { get; set; } [Required] public string? QueryText { get; set; } diff --git a/Interfaces/Cosmos.DataTransfer.Interfaces/ValidationExtensions.cs b/Interfaces/Cosmos.DataTransfer.Interfaces/ValidationExtensions.cs index 78230572..ad05f37c 100644 --- a/Interfaces/Cosmos.DataTransfer.Interfaces/ValidationExtensions.cs +++ b/Interfaces/Cosmos.DataTransfer.Interfaces/ValidationExtensions.cs @@ -4,7 +4,7 @@ namespace Cosmos.DataTransfer.Interfaces; public static class ValidationExtensions { - public static IEnumerable GetValidationErrors(this T? settings) + public static IEnumerable GetValidationErrors(this T? settings) where T : class, IDataExtensionSettings, new() { if (settings == null) @@ -18,7 +18,10 @@ public static class ValidationExtensions Validator.TryValidateObject(settings, context, results, true); foreach (var validationResult in results) { - yield return validationResult.ErrorMessage; + if (validationResult.ErrorMessage is not null) + { + yield return validationResult.ErrorMessage; + } } }