Skip to content

Commit

Permalink
Applying CR feedback and adding additional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
HowardWolosky committed Jul 15, 2020
1 parent ee72dcd commit fd2ab2e
Show file tree
Hide file tree
Showing 3 changed files with 238 additions and 147 deletions.
7 changes: 5 additions & 2 deletions GitHubCore.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ function Invoke-GHRestMethod

[string] $AcceptHeader = $script:defaultAcceptHeader,

[ValidateNotNullOrEmpty()]
[string] $InFile,

[string] $ContentType = $script:defaultJsonBodyContentType,
Expand All @@ -154,14 +155,14 @@ function Invoke-GHRestMethod
Invoke-UpdateCheck

# Minor error checking around $InFile
if ((-not [String]::IsNullOrWhiteSpace($InFile)) -and ($Method -ne 'Post'))
if ($PSBoundParameters.ContainsKey('InFile') -and ($Method -ne 'Post'))
{
$message = '-InFile may only be specified with Post requests.'
Write-Log -Message $message -Level Error
throw $message
}

if ((-not [String]::IsNullOrWhiteSpace($InFile)) -and (-not [String]::IsNullOrWhiteSpace($Body)))
if ($PSBoundParameters.ContainsKey('InFile') -and (-not [String]::IsNullOrWhiteSpace($Body)))
{
$message = 'Cannot specify BOTH InFile and Body'
Write-Log -Message $message -Level Error
Expand Down Expand Up @@ -238,6 +239,8 @@ function Invoke-GHRestMethod
if ($PSBoundParameters.ContainsKey('InFile') -and [String]::IsNullOrWhiteSpace($ContentType))
{
$file = Get-Item -Path $InFile
$localTelemetryProperties['FileExtension'] = $file.Extension

if ($script:extensionToContentType.ContainsKey($file.Extension))
{
$ContentType = $script:extensionToContentType[$file.Extension]
Expand Down
Loading

0 comments on commit fd2ab2e

Please sign in to comment.