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

New-DbaDbSequence - Don't use Test-Bound with defaults #7409

Merged
merged 10 commits into from
Jun 11, 2021

Conversation

andreasjordan
Copy link
Contributor

Type of Change

  • Bug fix (non-breaking change, fixes # )
  • New feature (non-breaking change, adds functionality, fixes # )
  • Breaking change (effects multiple commands or functionality, fixes # )
  • Ran manual Pester test and has passed (`.\tests\manual.pester.ps1)
  • Adding code coverage to existing functionality
  • Pester test is included
  • If new file reference added for test, has is been added to github.com/sqlcollaborative/appveyor-lab ?
  • Nunit test is included
  • Documentation
  • Build system

StartWith was not set when not explicitly set by parameter.

@andreasjordan
Copy link
Contributor Author

I don't have an idea why these two tests fail...

@andreasjordan
Copy link
Contributor Author

Open issue: The command returns just the plain SMO, all the other commands add ComputerName, InstanceName and SqlInstance and have a default view. That should be added here as well.
@lancasteradam : If you like, you can just close this pull request and open your own with all the necessary changes.

@andreasjordan
Copy link
Contributor Author

Test still fails and I don't have any idea. Can you please have a look @wsmelton - thanks.

@lancasteradam
Copy link
Contributor

The integration tests for min and max need these small changes shown below. This is because of the bugfix being made in this PR for the StartWith param in New-DbaDbSequence.ps1.

New-DbaDbSequence.Tests.ps1

Line 109:
$sequence = New-DbaDbSequence -SqlInstance $instance2 -Database $newDbName -Name "Sequence_$($randomForMinValues)" -Schema "Schema_$random" -MinValue $minValue -StartWith $minValue

and line 118:
$maxValues = @(10000, 100000)

For the New-DbaDbSequence.ps1 return object and default view this code could potentially be used:

$newSequence = $db | Get-DbaDbSequence -Name $newSequence.Name -Schema $newSequence.Schema
                    
Add-Member -Force -InputObject $newSequence -MemberType NoteProperty -Name ComputerName -value $db.Parent.ComputerName
Add-Member -Force -InputObject $newSequence -MemberType NoteProperty -Name InstanceName -value $db.Parent.ServiceName
Add-Member -Force -InputObject $newSequence -MemberType NoteProperty -Name SqlInstance -value $db.Parent.DomainInstanceName

Select-DefaultView -InputObject $newSequence -Property ComputerName, InstanceName, SqlInstance, Name, Schema, DataType, StartValue, IncrementValue, MinValue, MaxValue, CacheSize, IsCycleEnabled

@andreasjordan
Copy link
Contributor Author

Hi Adam, thanks for the hint, that changes to the test helped. Now only unrelated test fail.
The Add-Member and Select-DefaultView is not needed, that is already handled by the Get-DbaDbSequence - that is why we use the Get- to get the object.

@potatoqualitee
Copy link
Member

Thank you both! Re-running tests now 👍🏼

@potatoqualitee
Copy link
Member

All tests pass, merging! 😊

@potatoqualitee potatoqualitee merged commit 8f61611 into development Jun 11, 2021
@potatoqualitee potatoqualitee deleted the NewDbaDbSequence_Bugfix branch June 11, 2021 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants