Skip to content

Commit

Permalink
Fix parallel argument check.
Browse files Browse the repository at this point in the history
  • Loading branch information
fireflycons committed Sep 26, 2018
1 parent 2c1c927 commit 6dd07d0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
19 changes: 13 additions & 6 deletions Firefly.InvokeSqlExecute.PowerShell/InvokeSqlExecuteCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,9 @@ protected override void BeginProcessing()

if (!(ArgumentHelpers.IsEmptyArgument(this.ConnectionString)
|| ArgumentHelpers.IsEmptyArgument(this.InputFile))
&& this.ConnectionString.Length != this.InputFile.Length)
&& this.ConnectionString.Length != this.InputFile.Length
&& this.ConnectionString.Length > 1
&& this.InputFile.Length > 1)
{
// Must be 1 connection, many inputs or 1 input, many connections
throw new ArgumentException("Number of connection strings does not match number of input files. Must be 1 connection many files, or 1 file many connections, or an equal number of both.");
Expand Down Expand Up @@ -1139,11 +1141,16 @@ private void OnConnect(object sender, ConnectEventArgs args)
? WindowsIdentity.GetCurrent().Name
: connectionStringBuilder.UserID;

this.OnOutputMessage(sender, new OutputMessageEventArgs(args.NodeNumber, $"Connected to: [{args.Connection.DataSource}] as [{user}] ({authType})", OutputDestination.StdOut));
this.OnOutputMessage(sender, new OutputMessageEventArgs(args.NodeNumber, $"Version: {args.Connection.ServerVersion} {edition}", OutputDestination.StdOut));
this.OnOutputMessage(
sender,
new OutputMessageEventArgs(args.NodeNumber, $"Database: [{args.Connection.Database}]", OutputDestination.StdOut));
var msg = string.Join(
Environment.NewLine,
new List<string>()
{
$"Connected to: [{args.Connection.DataSource}] as [{user}] ({authType})",
$"Version: {args.Connection.ServerVersion} {edition}",
$"Database: [{args.Connection.Database}]"
});

this.OnOutputMessage(sender, new OutputMessageEventArgs(args.NodeNumber, msg, OutputDestination.StdOut));
}

/// <inheritdoc />
Expand Down
2 changes: 1 addition & 1 deletion Pester/SqlServer.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ Describe 'Parallel Execution' {

Context 'Should connect to all databases and run simple query in parallel' {

{ Invoke-SqlExecute -ConnectionString $instances.Connection -Parallel -Query "SELECT @@SERVERNAME" -OutputAs Text -Verbose } | Should Not Throw
{ Invoke-SqlExecute -ConnectionString $instances.Connection -Parallel -Query "SELECT @@SERVERNAME AS [InstanceName]" -OutputAs Text -Verbose } | Should Not Throw
}

Context 'Should run database creation script on multiple instances in parallel' {
Expand Down

0 comments on commit 6dd07d0

Please sign in to comment.