Skip to content

Commit 4094c5a

Browse files
Test output cleanup (#1895)
1 parent 5576f89 commit 4094c5a

File tree

7 files changed

+35
-19
lines changed

7 files changed

+35
-19
lines changed

src/Sentry.AspNetCore/ApplicationBuilderExtensions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ public static IApplicationBuilder UseSentry(this IApplicationBuilder app)
3232
var options = app.ApplicationServices.GetService<IOptions<SentryAspNetCoreOptions>>();
3333
if (options?.Value is { } o)
3434
{
35-
if (o.Debug && (o.DiagnosticLogger == null || o.DiagnosticLogger.GetType() == typeof(ConsoleDiagnosticLogger)))
35+
if (o.Debug && (o.DiagnosticLogger is null or ConsoleDiagnosticLogger ||
36+
o.DiagnosticLogger.GetType().Name == "TestOutputDiagnosticLogger"))
3637
{
3738
var logger = app.ApplicationServices.GetRequiredService<ILogger<ISentryClient>>();
3839
o.DiagnosticLogger = new MelDiagnosticLogger(logger, o.DiagnosticLevel);

src/Sentry/Internal/SentryScopeManager.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,12 @@ public KeyValuePair<Scope, ISentryClient> GetCurrent()
4242

4343
public void ConfigureScope(Action<Scope>? configureScope)
4444
{
45-
_options.LogDebug("Configuring the scope.");
4645
var scope = GetCurrent();
4746
configureScope?.Invoke(scope.Key);
4847
}
4948

5049
public Task ConfigureScopeAsync(Func<Scope, Task>? configureScope)
5150
{
52-
_options.LogDebug("Configuring the scope asynchronously.");
5351
var scope = GetCurrent();
5452
return configureScope?.Invoke(scope.Key) ?? Task.CompletedTask;
5553
}

test/Sentry.AspNetCore.Tests/IntegrationMockedBackgroundWorker.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@ public class IntegrationMockedBackgroundWorker : SentrySdkTestFixture
2020
private IBackgroundWorker Worker { get; set; } = Substitute.For<IBackgroundWorker>();
2121
protected Action<SentryAspNetCoreOptions> Configure;
2222

23-
public IntegrationMockedBackgroundWorker()
23+
public IntegrationMockedBackgroundWorker(ITestOutputHelper output)
2424
{
25-
ConfigureWehHost = builder =>
25+
ConfigureWebHost = builder =>
2626
{
2727
_ = builder.UseSentry(options =>
2828
{
2929
options.Dsn = ValidDsn;
3030
options.BackgroundWorker = Worker;
31+
options.DiagnosticLogger = new TestOutputDiagnosticLogger(output);
3132

3233
Configure?.Invoke(options);
3334
});
@@ -242,7 +243,7 @@ public async Task SendDefaultPii_TrueWithUserInRequest_UserNameSent()
242243
[Fact]
243244
public void AllSettingsViaJson()
244245
{
245-
ConfigureWehHost = b =>
246+
ConfigureWebHost = b =>
246247
{
247248
_ = b.ConfigureAppConfiguration(c =>
248249
{

test/Sentry.AspNetCore.Tests/SentrySdkTestFixture.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public abstract class SentrySdkTestFixture : IDisposable
1515

1616
public Action<IServiceCollection> ConfigureServices { get; set; }
1717
public Action<IApplicationBuilder> ConfigureApp { get; set; }
18-
public Action<IWebHostBuilder> ConfigureWehHost { get; set; }
18+
public Action<IWebHostBuilder> ConfigureWebHost { get; set; }
1919

2020
public LastExceptionFilter LastExceptionFilter { get; private set; }
2121

@@ -61,7 +61,7 @@ protected virtual void Build(string environment = default)
6161
});
6262
});
6363

64-
ConfigureWehHost?.Invoke(builder);
64+
ConfigureWebHost?.Invoke(builder);
6565
ConfigureBuilder(builder);
6666

6767
TestServer = new TestServer(builder);

test/Sentry.Maui.Tests/SentryMauiAppBuilderExtensionsTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public void CanUseSentry_WithConfigurationAndOptions()
9696
// Act
9797
var chainedBuilder = builder.UseSentry(options =>
9898
{
99-
options.Debug = true;
99+
options.Release = "test";
100100
});
101101

102102
using var app = builder.Build();
@@ -106,7 +106,7 @@ public void CanUseSentry_WithConfigurationAndOptions()
106106
Assert.Same(builder, chainedBuilder);
107107
Assert.True(SentrySdk.IsEnabled);
108108
Assert.Equal(ValidDsn, options.Dsn);
109-
Assert.True(options.Debug);
109+
Assert.Equal("test", options.Release);
110110
}
111111

112112
[Fact]

test/Sentry.Tests/EventProcessorTests.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1-
namespace Sentry.Tests;
1+
using Sentry.Testing;
2+
3+
namespace Sentry.Tests;
24

35
[UsesVerify]
46
public class EventProcessorTests
57
{
8+
private readonly TestOutputDiagnosticLogger _logger;
9+
10+
public EventProcessorTests(ITestOutputHelper output)
11+
{
12+
_logger = new TestOutputDiagnosticLogger(output);
13+
}
14+
615
[Fact]
716
public async Task Simple()
817
{
@@ -71,12 +80,13 @@ public class DiscardEventProcessor : ISentryEventProcessor
7180
public SentryEvent Process(SentryEvent @event) => null;
7281
}
7382

74-
private static SentryOptions Options(RecordingTransport transport) =>
83+
private SentryOptions Options(ITransport transport) =>
7584
new()
7685
{
7786
TracesSampleRate = 1,
7887
Debug = true,
7988
Transport = transport,
8089
Dsn = ValidDsn,
90+
DiagnosticLogger = _logger
8191
};
8292
}

test/Sentry.Tests/TransactionProcessorTests.cs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1-
namespace Sentry.Tests;
1+
using Sentry.Testing;
2+
3+
namespace Sentry.Tests;
24

35
[UsesVerify]
46
public class TransactionProcessorTests
57
{
8+
private readonly TestOutputDiagnosticLogger _logger;
9+
10+
public TransactionProcessorTests(ITestOutputHelper output)
11+
{
12+
_logger = new TestOutputDiagnosticLogger(output);
13+
}
14+
615
[Fact]
716
public async Task Simple()
817
{
@@ -37,11 +46,7 @@ public Transaction Process(Transaction transaction)
3746
public void SampledOut()
3847
{
3948
var transport = Substitute.For<ITransport>();
40-
var options = new SentryOptions
41-
{
42-
Transport = transport,
43-
Dsn = ValidDsn
44-
};
49+
var options = Options(transport);
4550
var processor = new TrackingProcessor();
4651
options.AddTransactionProcessor(processor);
4752
var transaction = new Transaction("name", "operation")
@@ -90,12 +95,13 @@ public Transaction Process(Transaction transaction) =>
9095
null;
9196
}
9297

93-
private static SentryOptions Options(RecordingTransport transport) =>
98+
private SentryOptions Options(ITransport transport) =>
9499
new()
95100
{
96101
TracesSampleRate = 1,
97102
Debug = true,
98103
Transport = transport,
99104
Dsn = ValidDsn,
105+
DiagnosticLogger = _logger
100106
};
101107
}

0 commit comments

Comments
 (0)