Skip to content

Commit 2612608

Browse files
fix: unit tests
1 parent 190ccd8 commit 2612608

2 files changed

Lines changed: 10 additions & 18 deletions

File tree

unit-tests/RepositoryTests/RepositoryTests.cs

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,22 @@ namespace RepositoryTests;
44

55
public class RepositoryTests
66
{
7-
private const string EnvFile = ".env";
8-
9-
[Test]
10-
public void TestMySqlEnvVarsConsistent()
11-
{
12-
Assert.That(File.Exists(EnvFile));
13-
DotEnv.Load(options: new DotEnvOptions(envFilePaths: [EnvFile]));
14-
15-
var testsDb = Environment.GetEnvironmentVariable("TESTS_DB");
16-
var mysqlConnectionString = Environment.GetEnvironmentVariable("MYSQL_CONNECTION_STRING");
17-
Assert.That(mysqlConnectionString, Is.Not.Null);
18-
var mysqlConnParts = mysqlConnectionString.Split(';');
19-
Assert.That(mysqlConnParts, Does.Contain($"database={testsDb}"));
20-
}
21-
227
[Test]
23-
public void TestPostgresEnvVarsConsistent()
8+
[TestCase(".env")]
9+
[TestCase(".benchmark.env")]
10+
public void TestPostgresEnvVarsConsistent(string envFile)
2411
{
25-
Assert.That(File.Exists(EnvFile));
26-
DotEnv.Load(options: new DotEnvOptions(envFilePaths: [EnvFile]));
12+
Assert.That(File.Exists(envFile));
13+
DotEnv.Load(options: new DotEnvOptions(envFilePaths: [envFile]));
2714

2815
var testsDb = Environment.GetEnvironmentVariable("TESTS_DB");
2916
var postgresUser = Environment.GetEnvironmentVariable("POSTGRES_USER");
3017
var postgresPassword = Environment.GetEnvironmentVariable("POSTGRES_PASSWORD");
3118
var postgresConnectionString = Environment.GetEnvironmentVariable("POSTGRES_CONNECTION_STRING");
19+
3220
Assert.That(postgresConnectionString, Is.Not.Null);
3321
var postgresConnParts = postgresConnectionString.Split(';');
22+
3423
Assert.That(postgresConnParts, Does.Contain($"database={testsDb}"));
3524
Assert.That(postgresConnParts, Does.Contain($"username={postgresUser}"));
3625
Assert.That(postgresConnParts, Does.Contain($"password={postgresPassword}"));

unit-tests/RepositoryTests/RepositoryTests.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
<Content Include="../../.env">
1313
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
1414
</Content>
15+
<Content Include="../../benchmark/.env" TargetPath=".benchmark.env">
16+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
17+
</Content>
1518
</ItemGroup>
1619

1720
<ItemGroup>

0 commit comments

Comments
 (0)