Skip to content

Commit

Permalink
ReportPortal.json configuration file as default (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
nvborisenko authored Feb 22, 2023
1 parent d2ff24c commit 08fffad
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/ReportPortal.Shared/Build/ReportPortal.Shared.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
<None Include="ReportPortal.config.json" Condition=" Exists('ReportPortal.config.json') ">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>

<None Include="ReportPortal.json" Condition=" Exists('ReportPortal.json') ">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 08fffad

Please sign in to comment.