File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed
Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,12 @@ function Show-Turtle
2929 $extensionPattern = " (?>$ ( $validExtensions -replace ' \.' , ' \.' -join ' |' ) )$"
3030 }
3131 process {
32+ # If we are not running interactively,
33+ # we obviously do not want to try to show something on the screen.
34+ if (-not [Environment ]::UserInteractive) {
35+ # Instead, just pass thru our input.
36+ return $InputObject
37+ }
3238 if ($InputObject -is [IO.FileInfo ] -and $InputObject.Extension -match $extensionPattern ) {
3339 Invoke-Item $InputObject.Fullname
3440 } elseif ($InputObject.pstypenames -contains ' Turtle' ) {
Original file line number Diff line number Diff line change @@ -66,5 +66,23 @@ describe Turtle {
6666 }
6767 }
6868
69-
69+ context ' Turtle Security' {
70+ it ' Can run in a data block' {
71+ $dataBlockTurtle = data - supportedCommand turtle, Get-Random {
72+ turtle rotate 45 forward (Get-Random - Min 21 - Max 42 )
73+ }
74+ $dataBlockTurtle.Heading | Should - Be 45
75+ }
76+ it ' Will not show a turtle in non-interactive mode' {
77+ if ([Environment ]::UserInteractive) {
78+ Write-Warning " Cannot test non-iteractivity interactively"
79+ } else {
80+ $dataBlockTurtle = data - supportedCommand turtle, Get-Random {
81+ turtle rotate 45 forward (Get-Random - Min 21 - Max 42 ) show
82+ }
83+ $dataBlockTurtle.Heading | Should - Be 45
84+ }
85+ }
86+ }
7087}
88+
You can’t perform that action at this time.
0 commit comments