-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #484 from microsoftgraph/bugfixes/InformationLogCl…
…eanUp Information Stream Cleanup
- Loading branch information
Showing
9 changed files
with
188 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
BeforeAll { | ||
$ModuleName = "Microsoft.Graph.Applications" | ||
$ModulePath = Join-Path $PSScriptRoot "..\$ModuleName.psd1" | ||
} | ||
|
||
Describe "Applications Module" { | ||
It "Module should be available when imported" { | ||
$LoadedModule = Get-Module -Name $ModuleName | ||
|
||
$LoadedModule | Should -Not -Be $null | ||
$LoadedModule.ExportedCommands.Count | Should -Not -Be 0 | ||
} | ||
|
||
It "Module import should not write to streams when debug preference is not set" { | ||
$ps = [powershell]::Create() | ||
$ps.AddScript("Import-Module $ModulePath").Invoke() | ||
|
||
$ps.Streams.Information.Count | Should -Be 0 | ||
$ps.Streams.Debug.Count | Should -Be 0 | ||
$ps.Streams.Error.Count | Should -Be 0 | ||
$ps.Streams.Verbose.Count | Should -Be 0 | ||
$ps.Streams.Warning.Count | Should -Be 0 | ||
$ps.Streams.Progress.Count | Should -Be 0 | ||
|
||
$ps.Dispose() | ||
} | ||
|
||
It "Module import should write to streams when debug preference is set" { | ||
$ps = [powershell]::Create() | ||
$ps.AddScript("`$DebugPreference = 'Inquire'; Import-Module $ModulePath").Invoke() | ||
|
||
$ps.Streams.Information.Count | Should -Be 0 | ||
$ps.Streams.Debug.Count | Should -Be 2 | ||
$ps.Streams.Error.Count | Should -Be 0 | ||
$ps.Streams.Verbose.Count | Should -Be 0 | ||
$ps.Streams.Warning.Count | Should -Be 0 | ||
$ps.Streams.Progress.Count | Should -Be 0 | ||
|
||
$ps.Dispose() | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/CloudCommunications/CloudCommunications/test/CloudCommunications.Tests.ps1
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,41 @@ | ||
BeforeAll { | ||
$ModuleName = "Microsoft.Graph.CloudCommunications" | ||
$ModulePath = Join-Path $PSScriptRoot "..\$ModuleName.psd1" | ||
} | ||
|
||
Describe "CloudCommunications Module" { | ||
It "Module should be available when imported" { | ||
$LoadedModule = Get-Module -Name $ModuleName | ||
|
||
$LoadedModule | Should -Not -Be $null | ||
$LoadedModule.ExportedCommands.Count | Should -Not -Be 0 | ||
} | ||
|
||
It "Module import should not write to streams when debug preference is not set" { | ||
$ps = [powershell]::Create() | ||
$ps.AddScript("Import-Module $ModulePath").Invoke() | ||
|
||
$ps.Streams.Information.Count | Should -Be 0 | ||
$ps.Streams.Debug.Count | Should -Be 0 | ||
$ps.Streams.Error.Count | Should -Be 0 | ||
$ps.Streams.Verbose.Count | Should -Be 0 | ||
$ps.Streams.Warning.Count | Should -Be 0 | ||
$ps.Streams.Progress.Count | Should -Be 0 | ||
|
||
$ps.Dispose() | ||
} | ||
|
||
It "Module import should write to streams when debug preference is set" { | ||
$ps = [powershell]::Create() | ||
$ps.AddScript("`$DebugPreference = 'Inquire'; Import-Module $ModulePath").Invoke() | ||
|
||
$ps.Streams.Information.Count | Should -Be 0 | ||
$ps.Streams.Debug.Count | Should -Be 2 | ||
$ps.Streams.Error.Count | Should -Be 0 | ||
$ps.Streams.Verbose.Count | Should -Be 0 | ||
$ps.Streams.Warning.Count | Should -Be 0 | ||
$ps.Streams.Progress.Count | Should -Be 0 | ||
|
||
$ps.Dispose() | ||
} | ||
} |
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,41 @@ | ||
BeforeAll { | ||
$ModuleName = "Microsoft.Graph.Users" | ||
$ModulePath = Join-Path $PSScriptRoot "..\$ModuleName.psd1" | ||
} | ||
|
||
Describe "Users Module" { | ||
It "Module should be available when imported" { | ||
$LoadedModule = Get-Module -Name $ModuleName | ||
|
||
$LoadedModule | Should -Not -Be $null | ||
$LoadedModule.ExportedCommands.Count | Should -Not -Be 0 | ||
} | ||
|
||
It "Module import should not write to streams when debug preference is not set" { | ||
$ps = [powershell]::Create() | ||
$ps.AddScript("Import-Module $ModulePath").Invoke() | ||
|
||
$ps.Streams.Information.Count | Should -Be 0 | ||
$ps.Streams.Debug.Count | Should -Be 0 | ||
$ps.Streams.Error.Count | Should -Be 0 | ||
$ps.Streams.Verbose.Count | Should -Be 0 | ||
$ps.Streams.Warning.Count | Should -Be 0 | ||
$ps.Streams.Progress.Count | Should -Be 0 | ||
|
||
$ps.Dispose() | ||
} | ||
|
||
It "Module import should write to streams when debug preference is set" { | ||
$ps = [powershell]::Create() | ||
$ps.AddScript("`$DebugPreference = 'Inquire'; Import-Module $ModulePath").Invoke() | ||
|
||
$ps.Streams.Information.Count | Should -Be 0 | ||
$ps.Streams.Debug.Count | Should -Be 2 | ||
$ps.Streams.Error.Count | Should -Be 0 | ||
$ps.Streams.Verbose.Count | Should -Be 0 | ||
$ps.Streams.Warning.Count | Should -Be 0 | ||
$ps.Streams.Progress.Count | Should -Be 0 | ||
|
||
$ps.Dispose() | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. | ||
param([string] $ModulePath, [string] $ModuleName, [switch]$Isolated) | ||
$ErrorActionPreference = 'Stop' | ||
|
||
# Install Pester | ||
if (!(Get-Module -Name Pester -ListAvailable)) { | ||
Install-Module -Name Pester -Force -SkipPublisherCheck | ||
} | ||
|
||
if(-not $Isolated) { | ||
Write-Host -ForegroundColor Green 'Creating isolated process...' | ||
$pwsh = [System.Diagnostics.Process]::GetCurrentProcess().Path | ||
& "$pwsh" -NonInteractive -NoLogo -NoProfile -File $MyInvocation.MyCommand.Path @PSBoundParameters -Isolated | ||
return | ||
} | ||
|
||
$modulePsd1 = Get-Item -Path (Join-Path $ModulePath "./$ModuleName.psd1") | ||
|
||
Import-Module -Name Pester | ||
Import-Module -Name $modulePsd1.FullName | ||
|
||
$testFolder = Join-Path $ModulePath 'test' | ||
$PesterConfiguration = [PesterConfiguration]::Default | ||
$PesterConfiguration.Run.Path = $testFolder | ||
$PesterConfiguration.Run.Exit = $true | ||
$PesterConfiguration.TestResult.OutputPath = (Join-Path $testFolder "$moduleName-TestResults.xml") | ||
|
||
try { | ||
Invoke-Pester -Configuration $PesterConfiguration | ||
} | ||
catch { | ||
throw $_ | ||
} | ||
|
||
Write-Host -ForegroundColor Green '-------------Done-------------' |