From 9b31e1b86d1a99eb684a3754085a7c4dfbf5b6df Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Thu, 10 Dec 2015 15:37:37 +1030 Subject: [PATCH] added the first few values necessary to run tests --- script/configure-integration-tests.ps1 | 49 ++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 script/configure-integration-tests.ps1 diff --git a/script/configure-integration-tests.ps1 b/script/configure-integration-tests.ps1 new file mode 100644 index 00000000..06ebbddd --- /dev/null +++ b/script/configure-integration-tests.ps1 @@ -0,0 +1,49 @@ +# TODO: this should indicate whether a variable is required or optional + +set-alias ?: Invoke-Ternary -Option AllScope -Description "PSCX filter alias" +filter Invoke-Ternary ([scriptblock]$decider, [scriptblock]$ifTrue, [scriptblock]$ifFalse) +{ + if (&$decider) { + &$ifTrue + } else { + &$ifFalse + } +} + +function VerifyEnvironmentVariable([string]$friendlyName, [string]$key, [bool]$optional = $false) +{ + $existing_value = [environment]::GetEnvironmentVariable($key,"User") + if ($existing_value -eq $null) + { + $value = Read-Host -Prompt "Set the $friendlyName to use for the integration tests " + (?: $optional "(required)" "(optional)") + [environment]::SetEnvironmentVariable($key, $value,"User") + } + else + { + Write-Host "$existing_value found as the configured $friendlyName" + $reset = Read-Host -Prompt "Want to change this? Press Y, otherwise we'll move on" + if ($reset -eq "Y") + { + $value = Read-Host -Prompt "Change the $friendlyName to use for the integration tests" + [environment]::SetEnvironmentVariable($key, $value, "User") + } + + if ($optional) + { + $clear = Read-Host -Prompt 'Want to remove this optional value, press Y' + if ($clear -eq "Y") + { + [Environment]::SetEnvironmentVariable($key,$null,"User") + } + } + } +} + +Write-Host "BIG FREAKING WARNING!!!!!" +Write-Host "You should use a test account when running the Octokit integration tests!" +Write-Host +Write-Host + +VerifyEnvironmentVariable "account name" "OCTOKIT_GITHUBUSERNAME" +VerifyEnvironmentVariable "organization name" "OCTOKIT_GITHUBORGANIZATION" $true +VerifyEnvironmentVariable "OAuth token" "OCTOKIT_OAUTHTOKEN"