|
| 1 | +# ------------------------------------------------------------------------------ |
| 2 | +# Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information. |
| 3 | +# ------------------------------------------------------------------------------ |
| 4 | +Describe "Microsoft.Graph.Users Module" { |
| 5 | + Context "On module import" { |
| 6 | + BeforeAll { |
| 7 | + $ModuleName = "Microsoft.Graph.Users" |
| 8 | + $ModulePath = Join-Path $PSScriptRoot "..\$ModuleName.psd1" |
| 9 | + $PSModuleInfo = Get-Module $ModuleName |
| 10 | + } |
| 11 | + |
| 12 | + It "Should have exported commands" { |
| 13 | + $PSModuleInfo | Should -Not -Be $null |
| 14 | + $PSModuleInfo.ExportedCommands.Count | Should -Not -Be 0 |
| 15 | + } |
| 16 | + |
| 17 | + It 'Should be compatible with PS core and desktop' { |
| 18 | + $PSModuleInfo.CompatiblePSEditions | Should -BeIn @("Core", "Desktop") |
| 19 | + } |
| 20 | + |
| 21 | + It 'Should point to script module' { |
| 22 | + $PSModuleInfo.Path | Should -BeLikeExactly "*$ModuleName.psm1" |
| 23 | + } |
| 24 | + |
| 25 | + It 'Should have a definition' { |
| 26 | + $PSModuleInfo.Definition | Should -Not -BeNullOrEmpty |
| 27 | + } |
| 28 | + |
| 29 | + It 'Should lock GUID' { |
| 30 | + $PSModuleInfo.Guid.Guid | Should -Be "71150504-37a3-48c6-82c7-7a00a12168db" |
| 31 | + } |
| 32 | + |
| 33 | + It "Module import should not write to error and information streams" { |
| 34 | + $ps = [powershell]::Create() |
| 35 | + $ps.AddScript("Import-Module $ModulePath -ErrorAction SilentlyContinue").Invoke() |
| 36 | + |
| 37 | + $ps.Streams.Information.Count | Should -Be 0 |
| 38 | + $ps.Streams.Error.Count | Should -Be 0 |
| 39 | + $ps.Streams.Verbose.Count | Should -Be 0 |
| 40 | + $ps.Streams.Warning.Count | Should -Be 0 |
| 41 | + $ps.Streams.Progress.Count | Should -Be 0 |
| 42 | + |
| 43 | + $ps.Dispose() |
| 44 | + } |
| 45 | + |
| 46 | + It "Get-MgUser should fail when auth session hasn't been initialized" { |
| 47 | + $ps = [powershell]::Create() |
| 48 | + $ps.AddScript("Import-Module $ModulePath -ErrorAction SilentlyContinue").Invoke() |
| 49 | + $ps.AddScript("Get-MgUser").Invoke() |
| 50 | + |
| 51 | + $ps.Streams.Information.Count | Should -Be 0 |
| 52 | + $ps.Streams.Verbose.Count | Should -Be 0 |
| 53 | + $ps.Streams.Warning.Count | Should -Be 0 |
| 54 | + $ps.Streams.Progress.Count | Should -Be 0 |
| 55 | + |
| 56 | + $ps.Streams.Error | Should -Be "$([Microsoft.Graph.PowerShell.Authentication.Core.ErrorConstants+Message]::MissingAuthContext)" |
| 57 | + |
| 58 | + $ps.Dispose() |
| 59 | + } |
| 60 | + } |
| 61 | +} |
0 commit comments