Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Mandatory from Test-PoshGitImportedInScript -Path #384

Merged
merged 2 commits into from
Jan 30, 2017
Merged
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
5 changes: 3 additions & 2 deletions src/Utils.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ function Add-PoshGitToProfile([switch]$AllHosts, [switch]$Force, [switch]$WhatIf
$profilePath = if ($AllHosts) { $PROFILE.CurrentUserAllHosts } else { $PROFILE.CurrentUserCurrentHost }

# Under test, we override some variables using $args as a backdoor.
if ($args.Count -gt 0) {
# TODO: Can we just turn these into optional parameters with well-defined behavior?
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rkeithhill this question is for you. Can we just make $ProfilePath and real (optional) argument that is documented to override $AllHosts?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, we could use environment variables to override.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather not make the public parameters any more complicated for the sake of tests. Yes, we could use env vars but those are global to the process and could impact tests if they ever ran in parallel (which they currently don't).

if (($args.Count -gt 0) -and ($args[0] -is [string])) {
$profilePath = [string]$args[0]
$underTest = $true
if ($args.Count -gt 1) {
Expand Down Expand Up @@ -205,7 +206,7 @@ function Test-InPSModulePath {

function Test-PoshGitImportedInScript {
param (
[Parameter(Position=0, Mandatory=$true)]
[Parameter(Position=0)]
[string]
$Path
)
Expand Down