2017-01-10 14:42:27 -08:00
|
|
|
if ( $IsWindows ) {
|
|
|
|
|
$PesterSkipOrPending = @{ Skip = $true }
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$PesterSkipOrPending = @{}
|
|
|
|
|
}
|
2016-07-25 14:01:41 -07:00
|
|
|
Describe "NativeLinuxCommands" -tags "CI" {
|
2017-02-16 04:40:51 +04:00
|
|
|
It "Should return a type of 'string' for hostname cmdlet" {
|
|
|
|
|
$result = hostname
|
|
|
|
|
$result | Should Not BeNullOrEmpty
|
|
|
|
|
$result | Should BeOfType string
|
2016-03-17 22:48:35 -07:00
|
|
|
}
|
|
|
|
|
|
2017-01-10 14:42:27 -08:00
|
|
|
It "Should find Application grep" @PesterSkipOrPending {
|
2016-04-08 13:36:54 -07:00
|
|
|
(get-command grep).CommandType | Should Be Application
|
2016-03-18 00:23:57 -07:00
|
|
|
}
|
|
|
|
|
|
2017-01-10 14:42:27 -08:00
|
|
|
It "Should pipe to grep and get result" @PesterSkipOrPending {
|
2016-04-08 13:36:54 -07:00
|
|
|
"hello world" | grep hello | Should Be "hello world"
|
2016-03-17 22:48:35 -07:00
|
|
|
}
|
2016-04-08 13:36:54 -07:00
|
|
|
|
2017-01-10 14:42:27 -08:00
|
|
|
It "Should find Application touch" @PesterSkipOrPending {
|
2016-04-08 13:36:54 -07:00
|
|
|
(get-command touch).CommandType | Should Be Application
|
2016-03-17 22:48:35 -07:00
|
|
|
}
|
2016-11-21 16:02:52 -08:00
|
|
|
|
2017-01-10 14:42:27 -08:00
|
|
|
It "Should not redirect standard input if native command is the first command in pipeline (1)" @PesterSkipOrPending {
|
2017-05-02 18:45:35 -07:00
|
|
|
df | ForEach-Object -Begin { $out = @() } -Process { $out += $_ }
|
2016-11-21 16:02:52 -08:00
|
|
|
$out.Length -gt 0 | Should Be $true
|
2017-05-02 18:45:35 -07:00
|
|
|
$out[0] -like "Filesystem*Available*" | Should Be $true
|
2016-11-21 16:02:52 -08:00
|
|
|
}
|
|
|
|
|
|
2017-01-10 14:42:27 -08:00
|
|
|
It "Should not redirect standard input if native command is the first command in pipeline (2)" @PesterSkipOrPending {
|
2017-05-02 18:45:35 -07:00
|
|
|
$out = df
|
2016-11-21 16:02:52 -08:00
|
|
|
$out.Length -gt 0 | Should Be $true
|
2017-05-02 18:45:35 -07:00
|
|
|
$out[0] -like "Filesystem*Available*" | Should Be $true
|
2016-11-21 16:02:52 -08:00
|
|
|
}
|
2016-03-17 22:48:35 -07:00
|
|
|
}
|
2016-05-27 11:43:05 -07:00
|
|
|
|
2016-07-25 14:01:41 -07:00
|
|
|
Describe "Scripts with extensions" -tags "CI" {
|
2016-05-27 11:43:05 -07:00
|
|
|
BeforeAll {
|
|
|
|
|
$data = "Hello World"
|
|
|
|
|
Setup -File testScript.ps1 -Content "'$data'"
|
|
|
|
|
$originalPath = $env:PATH
|
|
|
|
|
$env:PATH += [IO.Path]::PathSeparator + $TestDrive
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AfterAll {
|
|
|
|
|
$env:PATH = $originalPath
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
It "Should run a script with its full name" {
|
|
|
|
|
testScript.ps1 | Should Be $data
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
It "Should run a script with its short name" {
|
|
|
|
|
testScript | Should Be $data
|
|
|
|
|
}
|
|
|
|
|
}
|