From 08fffad7ae01dbf13327036f33928d22c7aef6eb Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> Date: Wed, 22 Feb 2023 12:37:46 +0300 Subject: [PATCH] ReportPortal.json configuration file as default (#115) --- src/ReportPortal.Shared/Build/ReportPortal.Shared.props | 4 ++++ .../Configuration/ConfigurationBuilderExtensions.cs | 1 + .../Configuration/ConfigurationBuilderTest.cs | 4 +++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ReportPortal.Shared/Build/ReportPortal.Shared.props b/src/ReportPortal.Shared/Build/ReportPortal.Shared.props index 2ffc1e55..a5f5a072 100644 --- a/src/ReportPortal.Shared/Build/ReportPortal.Shared.props +++ b/src/ReportPortal.Shared/Build/ReportPortal.Shared.props @@ -5,6 +5,10 @@ PreserveNewest + + + PreserveNewest + \ No newline at end of file diff --git a/src/ReportPortal.Shared/Configuration/ConfigurationBuilderExtensions.cs b/src/ReportPortal.Shared/Configuration/ConfigurationBuilderExtensions.cs index ba791701..0073d6c6 100644 --- a/src/ReportPortal.Shared/Configuration/ConfigurationBuilderExtensions.cs +++ b/src/ReportPortal.Shared/Configuration/ConfigurationBuilderExtensions.cs @@ -19,6 +19,7 @@ public static IConfigurationBuilder AddDefaults(this IConfigurationBuilder build { if (builder == null) throw new ArgumentNullException(nameof(builder)); + builder.AddJsonFile(Path.Combine(baseDir, "ReportPortal.json"), optional: true); builder.AddJsonFile(Path.Combine(baseDir, "ReportPortal.config.json"), optional: true); builder.AddDirectoryProbing(baseDir); builder.AddEnvironmentVariables(); diff --git a/test/ReportPortal.Shared.Tests/Configuration/ConfigurationBuilderTest.cs b/test/ReportPortal.Shared.Tests/Configuration/ConfigurationBuilderTest.cs index f59808d8..3a387adb 100644 --- a/test/ReportPortal.Shared.Tests/Configuration/ConfigurationBuilderTest.cs +++ b/test/ReportPortal.Shared.Tests/Configuration/ConfigurationBuilderTest.cs @@ -459,10 +459,12 @@ public void ShouldUseDefaultsWithBaseDir() var dir = Directory.CreateDirectory(Path.GetRandomFileName()); File.AppendAllText(dir + "/ReportPortal_prop1", "value1"); File.AppendAllText(dir + "/ReportPortal.config.json", @"{""prop2"": ""value2""}"); + File.AppendAllText(dir + "/ReportPortal.json", @"{""prop3"": ""value3""}"); var config = new ConfigurationBuilder().AddDefaults(dir.FullName).Build(); - config.Properties.Should().HaveCountGreaterOrEqualTo(2).And.ContainKeys("prop1", "prop2"); + config.Properties.Should().HaveCountGreaterOrEqualTo(3) + .And.ContainKeys("prop1", "prop2", "prop3"); dir.Delete(true); }