Skip to content

Commit

Permalink
fix: failed goodmessage
Browse files Browse the repository at this point in the history
Signed-off-by: SebastienDegodez <[email protected]>
  • Loading branch information
SebastienDegodez committed Dec 22, 2024
1 parent e0cda0e commit bc81b95
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 7 deletions.
10 changes: 8 additions & 2 deletions src/Microcks.Testcontainers/MicrocksBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
Expand Down Expand Up @@ -85,7 +85,8 @@ private void ContainerStarted(MicrocksContainer container)

if (_mainRemoteArtifacts != null && _mainRemoteArtifacts.Any())
{
_mainRemoteArtifacts.ForEach(remoteArtifactUrl => container.DownloadArtifactAsync(remoteArtifactUrl, main: true).GetAwaiter().GetResult());
_mainRemoteArtifacts.ForEach(remoteArtifactUrl =>
container.DownloadArtifactAsync(remoteArtifactUrl, main: true).GetAwaiter().GetResult());
}

if (_mainArtifacts != null && _mainArtifacts.Any())
Expand Down Expand Up @@ -148,6 +149,7 @@ public MicrocksBuilder WithSnapshots(params string[] snapshots)
{
_snapshots.AddRange(snapshots);
}

return this;
}

Expand All @@ -166,6 +168,7 @@ public MicrocksBuilder WithMainRemoteArtifacts(params string[] urls)
{
_mainRemoteArtifacts.AddRange(urls);
}

return this;
}

Expand All @@ -184,6 +187,7 @@ public MicrocksBuilder WithMainArtifacts(params string[] mainArtifacts)
{
_mainArtifacts.AddRange(mainArtifacts);
}

return this;
}

Expand All @@ -202,6 +206,7 @@ public MicrocksBuilder WithSecondaryArtifacts(params string[] secondaryArtifacts
{
_secondaryArtifacts.AddRange(secondaryArtifacts);
}

return this;
}

Expand All @@ -220,6 +225,7 @@ public MicrocksBuilder WithSecret(params Model.Secret[] secrets)
{
_secrets.AddRange(secrets);
}

return this;
}
}
18 changes: 18 additions & 0 deletions tests/Microcks.Testcontainers.Tests/Async/Kafka/KafkaCollection.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright The Microcks Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License")
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

namespace Microcks.Testcontainers.Tests.Async.Kafka;

[CollectionDefinition(nameof(KafkaCollection), DisableParallelization = true)]
public class KafkaCollection { }
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@
using FluentAssertions;
using Microcks.Testcontainers.Connection;
using Microcks.Testcontainers.Model;
using Microsoft.Extensions.Logging;
using Testcontainers.Kafka;

namespace Microcks.Testcontainers.Tests.Async.Kafka;

[Collection(nameof(KafkaCollection))]
public sealed class MicrocksAsyncKafkaFunctionalityTest : IAsyncLifetime
{
/// <summary>
Expand Down Expand Up @@ -132,11 +134,11 @@ public async Task ShouldReturnsCorrectStatusContractWhenGoodMessageIsEmitted()
.SetValueSerializer(Serializers.Utf8)
.SetErrorHandler((_, e) =>
{
Debug.WriteLine($"Error: {e.Reason}");
this._kafkaContainer.Logger.LogError("Error: {Reason}", e.Reason);
})
.SetLogHandler((_, logMessage) =>
{
Debug.WriteLine($"{logMessage.Name} sending {logMessage.Message}");
this._kafkaContainer.Logger.LogInformation("{Name} sending {Message}", logMessage.Name, logMessage.Message);
})
.Build();

Expand Down Expand Up @@ -202,11 +204,11 @@ public async Task ShouldReturnsCorrectStatusContractWhenBadMessageIsEmitted()
.SetValueSerializer(Serializers.Utf8)
.SetErrorHandler((_, e) =>
{
Debug.WriteLine($"Error: {e.Reason}");
this._kafkaContainer.Logger.LogError("Error: {Reason}", e.Reason);
})
.SetLogHandler((_, logMessage) =>
{
Debug.WriteLine($"{logMessage.Name} sending {logMessage.Message}");
this._kafkaContainer.Logger.LogInformation("{Name} sending {Message}", logMessage.Name, logMessage.Message);
})
.Build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
</Project>

0 comments on commit bc81b95

Please sign in to comment.