Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testcontainers.MsSql: WithDatabase to public #855

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions src/Testcontainers.MsSql/MsSqlBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,20 @@ public MsSqlBuilder WithPassword(string password)
.WithEnvironment("SQLCMDPASSWORD", password);
}

/// <summary>
/// Sets the MsSql database.
/// </summary>
/// <remarks>
/// The Docker image does not allow to configure the database.
/// </remarks>
/// <param name="database">The MsSql database.</param>
/// <returns>A configured instance of <see cref="MsSqlBuilder" />.</returns>
public MsSqlBuilder WithDatabase(string database)
{
return Merge(DockerResourceConfiguration, new MsSqlConfiguration(database: database))
.WithEnvironment("SQLCMDDBNAME", database);
}

/// <inheritdoc />
public override MsSqlContainer Build()
{
Expand Down Expand Up @@ -96,20 +110,6 @@ protected override MsSqlBuilder Merge(MsSqlConfiguration oldValue, MsSqlConfigur
return new MsSqlBuilder(new MsSqlConfiguration(oldValue, newValue));
}

/// <summary>
/// Sets the MsSql database.
/// </summary>
/// <remarks>
/// The Docker image does not allow to configure the database.
/// </remarks>
/// <param name="database">The MsSql database.</param>
/// <returns>A configured instance of <see cref="MsSqlBuilder" />.</returns>
private MsSqlBuilder WithDatabase(string database)
{
return Merge(DockerResourceConfiguration, new MsSqlConfiguration(database: database))
.WithEnvironment("SQLCMDDBNAME", database);
}

/// <summary>
/// Sets the MsSql username.
/// </summary>
Expand All @@ -131,7 +131,7 @@ private MsSqlBuilder WithUsername(string username)
/// </remarks>
private sealed class WaitUntil : IWaitUntil
{
private readonly string[] _command = { "/opt/mssql-tools/bin/sqlcmd", "-Q", "SELECT 1;" };
private readonly string[] _command = { "/opt/mssql-tools/bin/sqlcmd", "-d", "master", "-Q", "SELECT 1;" };

/// <inheritdoc />
public async Task<bool> UntilAsync(IContainer container)
Expand Down