Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/copilot-pull-request-description-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Pull Request Code Instructions

## PR TITLE

Follow this guidelines to construct the title of your pull request.

Format: `<type>(<scope>): <subject>`

`<scope>` is optional

## Example

```
feat: add hat wobble
^--^ ^------------^
| |
| +-> Summary in present tense.
|
+-------> Type: chore, docs, feat, fix, refactor, style, or test.
```

More Examples:

- `feat`: (new feature for the user, not a new feature for build script)
- `fix`: (bug fix for the user, not a fix to a build script)
- `docs`: (changes to the documentation)
- `style`: (formatting, missing semi colons, etc; no production code change)
- `refactor`: (refactoring production code, eg. renaming a variable)
- `test`: (adding missing tests, refactoring tests; no production code change)
- `chore`: (updating grunt tasks etc; no production code change)

References:

- https://www.conventionalcommits.org/
- https://seesparkbox.com/foundry/semantic_commit_messages
- http://karma-runner.github.io/1.0/dev/git-commit-msg.html

## Pull Reques description

- Add a summery of the intention of the PR. Use the title and the messages of the commits to create a summary.
- Add a list with all the commit messages in the PR.



40 changes: 40 additions & 0 deletions Test/include/parameter.test.helper.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Variables used to the written output of the cmdlets
#
# This definition allows to trace output streams for testing purposes
#
# sample usage:
#
# function Get-SomeCommand {
# [CmdletBinding()]
# param()
#
# Write-Verbose "this is a verbose message"
# }
#
# $result = Get-SomeCommand @ VerboseParameters
# Assert-Contains -Expected "this is a verbose message" -Presented $verboseVar

# Verbose parameters will now work.to capture the verbose outptut pipe 4>&1 and capture the output
# [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments','',Scope='function')]
# $VerboseParameters =@{
# VerboseAction = 'SilentlyContinue'
# VerboseVariable = 'verboseVar'
# }

[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments','',Scope='function')]
$WarningParameters = @{
WarningAction = 'SilentlyContinue'

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
WarningVariable = 'warningVar'
}

[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments','',Scope='function')]
$InfoParameters = @{
InformationAction = 'SilentlyContinue'
InformationVariable = 'infoVar'
}

[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments','',Scope='function')]
$ErrorParameters = @{
ErrorAction = 'SilentlyContinue'
ErrorVariable = 'errorVar'
}
25 changes: 25 additions & 0 deletions Test/include/transcriptHelp.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Test Transcript helper functions
# These functions help manage the transcript file during tests
# and ensure it is cleaned up after use.


$TEST_TRANSCRIPT_FILE = "test_transcript.log"

function Start-MyTranscript {

Check warning

Code scanning / PSScriptAnalyzer

Function 'Start-MyTranscript' has verb that could change system state. Therefore, the function has to support 'ShouldProcess'. Warning

Function 'Start-MyTranscript' has verb that could change system state. Therefore, the function has to support 'ShouldProcess'.
[CmdletBinding()]
param ()

if (Test-Path $TEST_TRANSCRIPT_FILE) {
Remove-Item -Path $TEST_TRANSCRIPT_FILE -Force
}

Start-Transcript -Path $TEST_TRANSCRIPT_FILE
}

function Stop-MyTranscript {

Check warning

Code scanning / PSScriptAnalyzer

Function 'Stop-MyTranscript' has verb that could change system state. Therefore, the function has to support 'ShouldProcess'. Warning

Function 'Stop-MyTranscript' has verb that could change system state. Therefore, the function has to support 'ShouldProcess'.
Stop-Transcript
$transcriptContent = Get-Content -Path $TEST_TRANSCRIPT_FILE
Remove-Item -Path $TEST_TRANSCRIPT_FILE
return $transcriptContent
}

28 changes: 14 additions & 14 deletions Test/private/mocks/hubbers.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"employment_type": "employee",
"github_login": "user3",
"msft_alias": "user3MSFT",
"name": "User Name 1",
"name": "Sarah Mitchell",
"email": "user3@github.com",
"title": "Chief Operating Officer",
"cost_center": "Strategic Operations",
Expand All @@ -16,7 +16,7 @@
"employment_type": "employee",
"github_login": "user1",
"msft_alias": "user1MSFT",
"name": "User Name 1",
"name": "Michael Johnson",
"email": "user1@github.com",
"title": "Chief Operating Officer",
"cost_center": "Strategic Operations",
Expand All @@ -28,7 +28,7 @@
"employment_type": "microsoft_employee",
"github_login": "user2",
"msft_alias": "user2MSFT",
"name": "User Name 2",
"name": "Jennifer Davis",
"email": "user2@github.com",
"title": "Chief Revenue Officer",
"cost_center": "Office of the CEO",
Expand All @@ -40,7 +40,7 @@
"employment_type": "microsoft_employee",
"github_login": "user0",
"msft_alias": "user0MSFT",
"name": "User Name 0",
"name": "Robert Thompson",
"email": "user0@github.com",
"title": "CEO",
"cost_center": "Office of the CEO",
Expand All @@ -52,7 +52,7 @@
"employment_type": "employee",
"github_login": "user4",
"msft_alias": "user4MSFT",
"name": "User Name 4",
"name": "Amanda Rodriguez",
"email": "user4@github.com",
"title": "Chief Product Officer",
"cost_center": "Product Management",
Expand All @@ -64,7 +64,7 @@
"employment_type": "microsoft_employee",
"github_login": "user5",
"msft_alias": "user5MSFT",
"name": "User Name 5",
"name": "David Wilson",
"email": "user5@github.com",
"title": "VP, Advisor to the CEO",
"cost_center": "Office of the CEO",
Expand All @@ -75,7 +75,7 @@
"employment_type": "employee",
"github_login": "user6",
"msft_alias": "user6MSFT",
"name": "User Name 6",
"name": "Lisa Anderson",
"email": "user6@github.com",
"title": "VP, COS to the CEO",
"cost_center": "Office of the CEO",
Expand All @@ -87,7 +87,7 @@
"employment_type": "microsoft_employee",
"github_login": "user7",
"msft_alias": "user7MSFT",
"name": "User Name 7",
"name": "Christopher Lee",
"email": "user7@github.com",
"title": "Chief Legal Officer",
"cost_center": "Legal",
Expand All @@ -98,7 +98,7 @@
"employment_type": "employee",
"github_login": "user8",
"msft_alias": "user8MSFT",
"name": "User Name 8",
"name": "Michelle Brown",
"email": "user8@github.com",
"title": "CISO",
"cost_center": "Security",
Expand All @@ -109,9 +109,9 @@
"manager": "user3",
"employment_type": "microsoft_employee",
"github_login": "user9",
"name": "Jay Parikh",
"name": "Daniel Martinez",
"user9MSFT": "jayparikh@github.com",
"title": "User Name 9",
"title": "CFO",
"cost_center": "user9 of the CEO",
"country": "United States of America"
},
Expand All @@ -120,7 +120,7 @@
"employment_type": "microsoft_employee",
"github_login": "user10",
"msft_alias": "user10MSFT",
"name": "User Name 10",
"name": "Ashley Taylor",
"email": "user10@github.com",
"title": "Chief People Officer",
"cost_center": "Office of the CEO",
Expand All @@ -131,7 +131,7 @@
"employment_type": "microsoft_employee",
"github_login": "user11",
"msft_alias": "user11MSFT",
"name": "User Name 11",
"name": "James Garcia",
"email": "user11h@github.com",
"title": "Chief Technology Officer",
"cost_center": "Office of the CEO",
Expand All @@ -142,7 +142,7 @@
"employment_type": "microsoft_employee",
"github_login": "user12",
"msft_alias": "user12MSFT",
"name": "User Name 12",
"name": "Emily White",
"email": "user12@github.com",
"title": "Chief Financial Officer",
"cost_center": "Office of the CEO",
Expand Down
56 changes: 56 additions & 0 deletions Test/public/searchhubber.test.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
function Test_searchHubber_Success_Name{

Reset-InvokeCommandMock
Mock_Database
$filePath = Get-MockFileFullPath -fileName "hubbers.json"
$result = Import-HubbersList -Path $filePath

$result = search-Hubber -Name "Mich"

$resultNames = $result.name
Assert-Count -Expected 2 -Presented $resultNames
Assert-Contains -Expected "Michael Johnson" -Presented $resultNames
Assert-Contains -Expected "Michelle Brown" -Presented $resultNames

}

function Test_searchHubber_Success_Handle{
Reset-InvokeCommandMock
Mock_Database
$filePath = Get-MockFileFullPath -fileName "hubbers.json"
$result = Import-HubbersList -Path $filePath

$result = search-Hubber -Handle "2"

$resultHandles = $result.github_login
Assert-Count -Expected 2 -Presented $resultHandles
Assert-Contains -Expected "user2" -Presented $resultHandles
Assert-Contains -Expected "user12" -Presented $resultHandles

}

function Test_searchHubber_Success_Name_Handle{
Reset-InvokeCommandMock
Mock_Database
$filePath = Get-MockFileFullPath -fileName "hubbers.json"
$result = Import-HubbersList -Path $filePath

$result = search-Hubber -Handle "2" -Name "Davis"

Assert-AreEqual -Expected "user2" -Presented $result.github_login
Assert-AreEqual -Expected "Jennifer Davis" -Presented $result.name
}



function Test_searchHubber_Fail_NoParams{
Reset-InvokeCommandMock
Mock_Database

Start-MyTranscript
$result = search-Hubber @ErrorParameters

Check warning

Code scanning / PSScriptAnalyzer

The variable 'result' is assigned but never used. Warning

The variable 'result' is assigned but never used.
$transcriptContent = Stop-MyTranscript

Assert-Contains -Expected "Error: Please specify either Name or Handle, or both." -Presented $transcriptContent

}
2 changes: 1 addition & 1 deletion public/getHubber.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
function Get-Hubber{
[CmdletBinding()]
param (
[Parameter(Position=0)][string]$Handle,
[Parameter(ValueFromPipeline,ValueFromPipelineByPropertyName,Position=0)][string]$Handle,

Check warning

Code scanning / PSScriptAnalyzer

Command accepts pipeline input but has not defined a process block. Warning

Command accepts pipeline input but has not defined a process block.

Check warning

Code scanning / PSScriptAnalyzer

Command accepts pipeline input but has not defined a process block. Warning

Command accepts pipeline input but has not defined a process block.
[Parameter()][switch]$AsHashtable
)

Expand Down
29 changes: 29 additions & 0 deletions public/searchhubber.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
function Search-Hubber {

Check notice

Code scanning / PSScriptAnalyzer

The cmdlet 'Search-Hubber' does not have a help comment. Note

The cmdlet 'Search-Hubber' does not have a help comment.
[CmdletBinding()]
param (
[Parameter(Position=0)][string]$Name,
[Parameter()][string]$Handle
)

$isName = -not [string]::IsNullOrEmpty($Name)
$isHandle = -not [string]::IsNullOrEmpty($Handle)

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
if( ! $isName -and ! $isHandle ) {
Write-MyError -Message "Please specify either Name or Handle, or both."
return $null
}

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
$hubbersList = Get-HubbersList

$hubbers = $hubbersList.Values

if ( $isHandle ) {
$hubbers = $hubbers | Where-Object { $_.github_login -like "*$Handle*" }
}

if ( $isName ) {
$hubbers = $hubbers | Where-Object { $_.name -like "*$Name*" }
}

return $hubbers
} Export-ModuleMember -Function Search-Hubber