Skip to content

Commit fc093d8

Browse files
committed
Fix/skip/comment broken tests
1 parent 107955c commit fc093d8

File tree

5 files changed

+80
-7
lines changed

5 files changed

+80
-7
lines changed

src/Configuration/src/SpringBoot/SpringBootEnvironmentVariableProvider.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ namespace Steeltoe.Configuration.SpringBoot;
1313
internal sealed class SpringBootEnvironmentVariableProvider : JsonStreamConfigurationProvider
1414
{
1515
private const string SpringApplicationJson = "SPRING_APPLICATION_JSON";
16+
private static readonly bool IsAtLeastDotNet10 = typeof(JsonStreamConfigurationProvider).Assembly.GetName().Version?.Major >= 10;
1617
private readonly string? _springApplicationJson;
1718
private bool _loaded;
1819

@@ -61,7 +62,8 @@ public override void Load()
6162
{
6263
string? value = Data[key];
6364

64-
if (value != null)
65+
// Breaking change in JsonConfigurationFileParser at https://github.com/dotnet/runtime/pull/116677.
66+
if (IsAtLeastDotNet10 || value != null)
6567
{
6668
string newKey = key.Contains('.') ? key.Replace('.', ':') : key;
6769
data[newKey] = value;

src/Configuration/test/SpringBoot.Test/SpringBootEnvironmentVariableProviderTest.cs

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,34 @@ public void TryGet_Tree()
6363
value.Should().Be("q");
6464

6565
provider.TryGet("r", out value).Should().BeTrue();
66+
#if NET10_0_OR_GREATER
67+
value.Should().BeNull();
68+
#else
6669
value.Should().BeEmpty();
70+
#endif
6771

6872
provider.TryGet("s:t", out value).Should().BeTrue();
73+
#if NET10_0_OR_GREATER
74+
value.Should().BeNull();
75+
#else
6976
value.Should().BeEmpty();
77+
#endif
7078

79+
#if NET10_0_OR_GREATER
80+
provider.TryGet("u", out _).Should().BeTrue();
81+
// Needs investigation: what does this mean for the options binder?
82+
value.Should().BeNull();
83+
#else
7184
provider.TryGet("u", out _).Should().BeFalse();
85+
#endif
7286

87+
#if NET10_0_OR_GREATER
88+
provider.TryGet("v:w", out _).Should().BeTrue();
89+
// Needs investigation: what does this mean for the options binder?
90+
value.Should().BeNull();
91+
#else
7392
provider.TryGet("v:w", out _).Should().BeFalse();
93+
#endif
7494
}
7595

7696
[Fact]
@@ -113,14 +133,32 @@ public void TryGet_Array()
113133
value.Should().Be("q");
114134

115135
provider.TryGet("a:b:c:2:r", out value).Should().BeTrue();
136+
#if NET10_0_OR_GREATER
137+
value.Should().BeNull();
138+
#else
116139
value.Should().BeEmpty();
140+
#endif
117141

118142
provider.TryGet("a:b:c:2:s:t", out value).Should().BeTrue();
143+
#if NET10_0_OR_GREATER
144+
value.Should().BeNull();
145+
#else
119146
value.Should().BeEmpty();
120-
121-
provider.TryGet("a:b:c:3:u", out _).Should().BeFalse();
122-
123-
provider.TryGet("a:b:c:3:v:w", out _).Should().BeFalse();
147+
#endif
148+
149+
#if NET10_0_OR_GREATER
150+
provider.TryGet("a:b:c:2:u", out _).Should().BeTrue();
151+
value.Should().BeNull();
152+
#else
153+
provider.TryGet("a:b:c:2:u", out _).Should().BeFalse();
154+
#endif
155+
156+
#if NET10_0_OR_GREATER
157+
provider.TryGet("a:b:c:2:v:w", out _).Should().BeTrue();
158+
value.Should().BeNull();
159+
#else
160+
provider.TryGet("a:b:c:2:v:w", out _).Should().BeFalse();
161+
#endif
124162
}
125163

126164
[Fact]

src/Connectors/test/EntityFrameworkCore.Test/MySql/Pomelo/MySqlDbContextOptionsBuilderExtensionsTest.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ namespace Steeltoe.Connectors.EntityFrameworkCore.Test.MySql.Pomelo;
1616

1717
public sealed class MySqlDbContextOptionsBuilderExtensionsTest
1818
{
19+
#if NET10_0_OR_GREATER
20+
[Fact(Skip = "Disabled because there is no Pomelo version that's compatible with EF Core 10 yet.")]
21+
#else
1922
[Fact]
23+
#endif
2024
public async Task Registers_connection_string_for_default_service_binding()
2125
{
2226
var appSettings = new Dictionary<string, string?>
@@ -42,7 +46,11 @@ public async Task Registers_connection_string_for_default_service_binding()
4246
"Server=localhost;User ID=steeltoe;Password=steeltoe;Database=myDb;Allow User Variables=True;Connection Timeout=15;Use Affected Rows=False;Use Compression=False");
4347
}
4448

49+
#if NET10_0_OR_GREATER
50+
[Fact(Skip = "Disabled because there is no Pomelo version that's compatible with EF Core 10 yet.")]
51+
#else
4552
[Fact]
53+
#endif
4654
public async Task Registers_connection_string_for_named_service_binding()
4755
{
4856
var appSettings = new Dictionary<string, string?>

src/Logging/test/DynamicConsole.Test/DynamicConsoleLoggerProviderTest.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,29 @@ public async Task CanUseJsonFormatterWithScopes()
482482
await _consoleOutput.WaitForFlushAsync(TestContext.Current.CancellationToken);
483483
string logOutput = _consoleOutput.ToString();
484484

485+
#if NET10_0_OR_GREATER
486+
logOutput.Should().Be("""
487+
{
488+
"EventId": 0,
489+
"LogLevel": "Information",
490+
"Category": "Fully.Qualified.Type",
491+
"Message": "Processing of { RequestUrl = https://www.example.com, UserAgent = Steeltoe } started.",
492+
"State": {
493+
"@IncomingRequest": "{ RequestUrl = https://www.example.com, UserAgent = Steeltoe }",
494+
"{OriginalFormat}": "Processing of {@IncomingRequest} started."
495+
},
496+
"Scopes": [
497+
"OuterScope",
498+
{
499+
"Message": "InnerScope=InnerScopeValue",
500+
"InnerScopeKey": "InnerScopeValue",
501+
"{OriginalFormat}": "InnerScope={InnerScopeKey}"
502+
}
503+
]
504+
}
505+
506+
""");
507+
#else
485508
logOutput.Should().Be("""
486509
{
487510
"EventId": 0,
@@ -504,6 +527,7 @@ public async Task CanUseJsonFormatterWithScopes()
504527
}
505528
506529
""");
530+
#endif
507531
}
508532

509533
[Fact]

src/Tools/test/ConfigurationSchemaGenerator.Tests/ConfigurationSchemaGenerator.Tests.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<TargetFrameworks>net10.0;net9.0;net8.0</TargetFrameworks>
44
<IsPackable>false</IsPackable>
@@ -24,7 +24,8 @@
2424

2525
<ItemGroup>
2626
<PackageReference Include="coverlet.collector" Version="$(CoverletVersion)" PrivateAssets="All" />
27-
<PackageReference Include="Microsoft.Extensions.Hosting" Version="$(FoundationalVersion)" />
27+
<PackageReference Include="Microsoft.Extensions.Hosting" Condition="'$(TargetFramework)' == 'net10.0'" Version="$(MatchTargetFrameworkVersion)" />
28+
<PackageReference Include="Microsoft.Extensions.Hosting" Condition="'$(TargetFramework)' != 'net10.0'" Version="$(FoundationalVersion)" />
2829
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(TestSdkVersion)" />
2930
<PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonVersion)" />
3031
<PackageReference Include="xunit.v3" Version="$(XunitVersion)" />

0 commit comments

Comments
 (0)