Skip to content

Commit

Permalink
Merge pull request #56 from theohbrothers/fix/tests-use-scope-it-for-…
Browse files Browse the repository at this point in the history
…all-unit-tests-using-assert-mockedcalled

Fix (tests): Use -Scope It for all unit tests using `Assert-MockedCalled`
  • Loading branch information
leojonathanoh authored Sep 12, 2021
2 parents 1909aa8 + 707ccef commit 73cf527
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ Describe "New-GenerationFolder" -Tag 'Unit' {

New-GenerationFolder -GenerateConfig $GenerateConfig 6>$null

Assert-MockCalled New-Item -Times 5
Assert-MockCalled Get-Content -Times 2
Assert-MockCalled Out-File -Times 2
Assert-MockCalled New-Item -Times 5 -Scope It
Assert-MockCalled Get-Content -Times 2 -Scope It
Assert-MockCalled Out-File -Times 2 -Scope It
}

It 'Does not recreate existing folders and files' {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Describe "New-RepositoryFile" -Tag 'Unit' {

$file | New-RepositoryFile 6>$null

Assert-MockCalled Out-File -Times 1
Assert-MockCalled Out-File -Times 1 -Scope It
}

}
Expand All @@ -46,7 +46,7 @@ Describe "New-RepositoryFile" -Tag 'Unit' {

New-RepositoryFile -File $file 6>$null

Assert-MockCalled New-Item -Times 1
Assert-MockCalled New-Item -Times 1 -Scope It
}

It "Creates a file" {
Expand All @@ -64,7 +64,7 @@ Describe "New-RepositoryFile" -Tag 'Unit' {

New-RepositoryFile -File $file 6>$null

Assert-MockCalled Get-ContentFromTemplate -Times 1
Assert-MockCalled Get-ContentFromTemplate -Times 1 -Scope It
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Describe "New-RepositoryVariantBuildContext" -Tag 'Unit' {

$variant | New-RepositoryVariantBuildContext 6>$null

Assert-MockCalled New-Item -Times 1
Assert-MockCalled New-Item -Times 1 -Scope It

}

Expand All @@ -38,7 +38,7 @@ Describe "New-RepositoryVariantBuildContext" -Tag 'Unit' {

New-RepositoryVariantBuildContext -Variant $variant 6>$null

Assert-MockCalled New-Item -Times 1
Assert-MockCalled New-Item -Times 1 -Scope It
}

It "Creates files from templates" {
Expand Down Expand Up @@ -69,8 +69,8 @@ Describe "New-RepositoryVariantBuildContext" -Tag 'Unit' {

New-RepositoryVariantBuildContext -Variant $variant 6>$null

Assert-MockCalled New-Item -Times 1
Assert-MockCalled Out-File -Times 1
Assert-MockCalled New-Item -Times 1 -Scope It
Assert-MockCalled Out-File -Times 1 -Scope It
}

It "Creates files from copies" {
Expand All @@ -87,7 +87,7 @@ Describe "New-RepositoryVariantBuildContext" -Tag 'Unit' {

New-RepositoryVariantBuildContext -Variant $variant 6>$null

Assert-MockCalled Copy-Item -Times 1
Assert-MockCalled Copy-Item -Times 1 -Scope It
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Describe "Generate-DockerImageVariants" -Tag 'Unit' {

Generate-DockerImageVariants -ProjectPath $projectPath -Init

Assert-MockCalled New-GenerationFolder -Times 1
Assert-MockCalled New-GenerationFolder -Times 1 -Scope It
}

It 'Gets variants definitions' {
Expand All @@ -45,7 +45,7 @@ Describe "Generate-DockerImageVariants" -Tag 'Unit' {

Generate-DockerImageVariants -ProjectPath $projectPath

Assert-MockCalled Get-Definition -Times 2
Assert-MockCalled Get-Definition -Times 2 -Scope It
}

It 'Gets variants and files definitions' {
Expand All @@ -66,7 +66,7 @@ Describe "Generate-DockerImageVariants" -Tag 'Unit' {

Generate-DockerImageVariants -ProjectPath $projectPath

Assert-MockCalled Get-Definition -Times 3
Assert-MockCalled Get-Definition -Times 3 -Scope It
}

It 'Gets variants and files definitions' {
Expand All @@ -87,7 +87,7 @@ Describe "Generate-DockerImageVariants" -Tag 'Unit' {

Generate-DockerImageVariants -ProjectPath $projectPath

Assert-MockCalled Get-Definition -Times 3
Assert-MockCalled Get-Definition -Times 3 -Scope It
}

It 'Validates variants definitions' {
Expand All @@ -108,7 +108,7 @@ Describe "Generate-DockerImageVariants" -Tag 'Unit' {

Generate-DockerImageVariants -ProjectPath $projectPath

Assert-MockCalled Validate-Object -Times 1
Assert-MockCalled Validate-Object -Times 1 -Scope It
}

It 'Validates variants and files definition' {
Expand All @@ -131,7 +131,7 @@ Describe "Generate-DockerImageVariants" -Tag 'Unit' {

Generate-DockerImageVariants -ProjectPath $projectPath

Assert-MockCalled Validate-Object -Times 2
Assert-MockCalled Validate-Object -Times 2 -Scope It
}

It 'Populates variants and files definition' {
Expand All @@ -152,7 +152,7 @@ Describe "Generate-DockerImageVariants" -Tag 'Unit' {

Generate-DockerImageVariants -ProjectPath $projectPath

Assert-MockCalled Populate-GenerateConfig -Times 1
Assert-MockCalled Populate-GenerateConfig -Times 1 -Scope It
}

It 'Generates target repository variant build context' {
Expand All @@ -176,7 +176,7 @@ Describe "Generate-DockerImageVariants" -Tag 'Unit' {

Generate-DockerImageVariants -ProjectPath $projectPath

Assert-MockCalled New-RepositoryVariantBuildContext -Times 1
Assert-MockCalled New-RepositoryVariantBuildContext -Times 1 -Scope It
}

It 'Generates target repository files' {
Expand All @@ -197,7 +197,7 @@ Describe "Generate-DockerImageVariants" -Tag 'Unit' {

Generate-DockerImageVariants -ProjectPath $projectPath

Assert-MockCalled New-RepositoryFile -Times 1
Assert-MockCalled New-RepositoryFile -Times 1 -Scope It
}

}
Expand Down

0 comments on commit 73cf527

Please sign in to comment.