-
-
Notifications
You must be signed in to change notification settings - Fork 292
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added default database configuration model, part of #45.
- Loading branch information
1 parent
95729ac
commit ca4a74a
Showing
13 changed files
with
106 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 0 additions & 25 deletions
25
src/DotNet.Testcontainers/Core/Builder/TestcontainersBuilderExtensions.cs
This file was deleted.
Oops, something went wrong.
37 changes: 37 additions & 0 deletions
37
src/DotNet.Testcontainers/Core/Builder/TestcontainersBuilderPostgreSqlExtension.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
namespace DotNet.Testcontainers.Core.Builder | ||
{ | ||
using DotNet.Testcontainers.Core.Containers.Database; | ||
using DotNet.Testcontainers.Core.Models; | ||
|
||
public static class TestcontainersBuilderPostgreSqlExtension | ||
{ | ||
private const string DefaultImage = "postgres:11.2"; | ||
|
||
private const string DefaultPort = "5432"; | ||
|
||
private const string Database = "POSTGRES_DB"; | ||
|
||
private const string Username = "POSTGRES_USER"; | ||
|
||
private const string Password = "POSTGRES_PASSWORD"; | ||
|
||
public static ITestcontainersBuilder<T> WithDatabase<T>(this ITestcontainersBuilder<T> builder, DatabaseConfiguration configuration) | ||
where T : PostgreSqlContainer | ||
{ | ||
return builder | ||
.WithImage(DefaultImage) | ||
.WithPortBinding(DefaultPort) | ||
.WithEnvironment(Database, configuration.Database) | ||
.WithEnvironment(Username, configuration.Username) | ||
.WithEnvironment(Password, configuration.Password) | ||
.ConfigureContainer((container) => | ||
{ | ||
container.Hostname = configuration.Hostname; | ||
container.Port = configuration.Port; | ||
container.Database = configuration.Database; | ||
container.Username = configuration.Username; | ||
container.Password = configuration.Password; | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/DotNet.Testcontainers/Core/Models/DatabaseConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
namespace DotNet.Testcontainers.Core.Models | ||
{ | ||
public class DatabaseConfiguration | ||
{ | ||
public virtual string Hostname { get; set; } = "localhost"; | ||
|
||
public virtual string Port { get; set; } | ||
|
||
public virtual string Database { get; set; } | ||
|
||
public virtual string Username { get; set; } | ||
|
||
public virtual string Password { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters