From 7f76b715022336b7d65b873369802c08a75b8301 Mon Sep 17 00:00:00 2001 From: Raymond Piller Date: Sun, 22 Jul 2018 01:08:45 -0500 Subject: [PATCH] Added more Code Cov - Also, more production clean up --- QuserObject/Manifest.json | 2 +- QuserObject/en-US/about_QuserObject.help.text | 23 +++++------- Tests/QuserObject.Tests.ps1 | 35 +++++++++++++++++++ 3 files changed, 44 insertions(+), 16 deletions(-) create mode 100644 Tests/QuserObject.Tests.ps1 diff --git a/QuserObject/Manifest.json b/QuserObject/Manifest.json index bd3782e..2381555 100644 --- a/QuserObject/Manifest.json +++ b/QuserObject/Manifest.json @@ -5,7 +5,7 @@ "Author": "Raymond Piller", "CompanyName": "Computing for Arts + Sciences, University of North Texas", "Copyright": "(c) {0} University of North Texas. All rights reserved.", - "GUID": "5d6f5c02-3a3d-457e-a20b-49e356bbdd44", + "GUID": "cd53e7be-8e24-43b5-91bc-6828fc1500a5", "RootModule": "QuserObject.psm1", "PowerShellVersion": "5.0", "HelpInfoURI": "https://github.com/UNT-CAS/QuserObject" diff --git a/QuserObject/en-US/about_QuserObject.help.text b/QuserObject/en-US/about_QuserObject.help.text index 4f101bf..e518a09 100644 --- a/QuserObject/en-US/about_QuserObject.help.text +++ b/QuserObject/en-US/about_QuserObject.help.text @@ -2,24 +2,17 @@ PSTOPIC about_QuserObject SHORT DESCRIPTION - Manage concurrent usage of software that doesn't use a smarter license server, such as Flex LM. + Run `quser.exe` and return a proper PowerShell Object. LONG DESCRIPTION - We have several pieces of software that don't use a license server. Because of this, we own n number of stand-alone licenses. - When applicable, we can install this on as many computers as we want, such as in a VDI farm, and make it availble as long as we can control concurrency. - This is an attempt to control concurrency in these situations. + Run `quser.exe` and return a proper PowerShell Object. + I discussed this on my blog to enhance a StackOverflow answer. + I thought I'd make this into a PowerShell module for ease of use and distribution. DETAILED DESCRIPTION - We have several pieces of software that don't use a license server. Because of this, we own n number of stand-alone licenses. - When applicable, we can install this on as many computers as we want, such as in a VDI farm, and make it availble as long as we can control concurrency. - This is an attempt to control concurrency in these situations. - - I prefer to run this as a scheduled task that triggers at reboot and re-runs every 15 minutes or so; ensure: - - - If it's already running, another one doesn't startup. - - It's never forced to die after a timeout. - - This ensure that the process is always running. If it dies for some reason, we'll get it running again within 15 minutes - + Run `quser.exe` and return a proper PowerShell Object. + I discussed this on my blog to enhance a StackOverflow answer. + I thought I'd make this into a PowerShell module for ease of use and distribution. + You can find documentation here: https://github.com/UNT-CAS/QuserObject \ No newline at end of file diff --git a/Tests/QuserObject.Tests.ps1 b/Tests/QuserObject.Tests.ps1 new file mode 100644 index 0000000..175423d --- /dev/null +++ b/Tests/QuserObject.Tests.ps1 @@ -0,0 +1,35 @@ +[string] $projectDirectoryName = 'QuserObject' +[IO.FileInfo] $pesterFile = [io.fileinfo] ([string] (Resolve-Path -Path $MyInvocation.MyCommand.Path)) +[IO.DirectoryInfo] $projectRoot = Split-Path -Parent $pesterFile.Directory +[IO.DirectoryInfo] $projectDirectory = Join-Path -Path $projectRoot -ChildPath $projectDirectoryName -Resolve +[IO.FileInfo] $testFile = Join-Path -Path $projectDirectory -ChildPath ($pesterFile.Name -replace '\.Tests\.ps1', '.psm1') -Resolve + +Describe $testFile.Name { + It 'Import-Module' { + { Import-Module $testFile } | Should Not Throw + } + + It 'Imported' { + Get-Module $projectDirectoryName | Should Not BeNullOrEmpty + } + + $public = @( Get-ChildItem -Path "${projectDirectory}\Public\*.ps1" -ErrorAction SilentlyContinue ) + + Context 'Public Functions' { + foreach ($file in $public) { + It "Exists: $($file.BaseName)" { + Get-Command $file.BaseName -ErrorAction SilentlyContinue | Should Not BeNullOrEmpty + } + } + } + + $private = @( Get-ChildItem -Path "${projectDirectory}\Private\*.ps1" -ErrorAction SilentlyContinue ) + + Context 'Private Functions' { + foreach ($file in $Private) { + It "Not Exists: $($file.BaseName)" { + Get-Command $file.BaseName -ErrorAction SilentlyContinue | Should BeNullOrEmpty + } + } + } +} \ No newline at end of file