Skip to content

Commit 888da44

Browse files
committed
fix: Avoid including container types from utilized modules in unrelated tests
1 parent f1b2e0b commit 888da44

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tests/Testcontainers.Databases.Tests/DatabasesContainerTest.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,19 @@ public static TheoryData<Type> GetContainerImplementations(bool expectDataProvid
4040
// TODO: If a module contains multiple container implementations, it would require all container implementations to implement the interface.
4141
foreach (var containerType in testAssembly.Value.Where(type => type.IsAssignableTo(typeof(IContainer))))
4242
{
43+
var testAssemblyName = testAssembly.Key.GetName().Name!;
44+
45+
var containerTypeAssemblyName = containerType.Assembly.GetName().Name!;
46+
47+
// If a module utilizes another one of our modules, do not include the container type
48+
// if it does not belong to the actual module. For example, the ServiceBus module
49+
// utilizes the MsSql module. We do not want to include the MsSqlContainer type
50+
// twice or place it in the wrong test.
51+
if (!testAssemblyName.Contains(containerTypeAssemblyName, StringComparison.OrdinalIgnoreCase))
52+
{
53+
continue;
54+
}
55+
4356
var hasDataProvider = testAssembly.Value.Exists(type => type.IsSubclassOf(typeof(DbProviderFactory)));
4457

4558
if (expectDataProvider && hasDataProvider)

0 commit comments

Comments
 (0)