Commit graph

24 commits

Author SHA1 Message Date
xtqqczze f4382202ae
Use correct casing for cmdlet name and cmdlet parameter name in *.ps1 files (#12584) 2020-05-07 17:00:30 +05:00
Steve Lee b7cb335f03
Update copyright notice to latest guidance (#12190) 2020-03-24 11:08:37 -07:00
xtqqczze 920b671fb4 Unify pester test syntax for the arguments of -BeOfType (#11558) 2020-01-24 11:00:37 -08:00
xtqqczze e0d2e2aade Correct case of $PSHOME special variable 2020-01-13 19:35:33 +00:00
xtqqczze 743983390e Update pester syntax to v4 (#11544)
* Capitalize 'Should' command and fix whitespace

```powershell
$_ -ireplace '\s?\|\s?should\b',' | Should'
```

* Capitalise and apply hyphen to 'Not' parameter

```powershell
$_ -ireplace '(\| Should) not\b','$1 -Not'
```

* Capitalise and apply hyphen to 'Be' parameter

```powershell
$_ -ireplace '(\| Should(?: -Not)?) -?be\b','$1 -Be'
```

* Capitalise and apply hyphen to 'BeExactly' parameter

$_ -ireplace '(\| Should(?: -Not)?) -?beexactly\b','$1 -BeExactly'

* Capitalise and apply hyphen to 'BeGreaterThan' parameter

```powershell
$_ -ireplace '(\| Should(?: -Not)?) -?begreaterthan\b','$1 -BeGreaterThan'
```

* Use 'BeTrue' parameter

```powershell
$_ -ireplace '(\| Should(?: -Not)?) -Be\s\$?true\b','$1 -BeTrue'
```

* Use 'BeFalse' parameter

```powershell
$_ -ireplace '(\| Should(?: -Not)?) -Be\s\$?false\b','$1 -BeFalse'
```

* Capitalise and apply hyphen to 'Match' parameter

```powershell
$_ -ireplace '(\| Should(?: -Not)?)\s-?match\b','$1 -Match'
```

* Capitalise and apply hyphen to 'Throw' parameter

```powershell
$_ -ireplace '(\| Should(?: -Not)?)\s-?throw\b','$1 -Throw'
```

* Capitalise and apply hyphen to 'BeNullOrEmpty' parameter

```powershell
$_ -ireplace '(\| Should(?: -Not)?)\s-?benullorempty\b','$1 -BeNullOrEmpty'
```

* Capitalise 'Because' parameter

```powershell
$_ -ireplace '\s-because\b',' -Because'
```

* Fix 'BeNullOrEmpty'
2020-01-11 20:41:59 +05:00
xtqqczze 7a7365279c Avoid variable names that conflict with automatic variables (#11392) 2019-12-20 12:09:03 -08:00
Aditya Patwardhan ade85b4faa
Multiple test fixes and improved logging for fragile tests (#9569) 2019-05-10 10:56:12 -07:00
Steve Lee b63696572f Fix skipping of tests in RemoteSession.Basic.Tests.ps1 (#9304)
Moved check if able to write to $PSHome as way to skip test to `BeforeAll` which already contained a check if running on Windows.

## PR Context

As part https://github.com/PowerShell/PowerShell/pull/9279, tests were updated to be skipped if the test requires writing to `$PSHome` but is not able to.  However, these tests already had a skip mechanism in place so the additional check caused the test to run when it should have skipped.

Co-authored-by: Travis Plunk <github@ez13.net>
2019-04-05 17:00:41 -07:00
Steve Lee b8317de469 Update tests to account for when $PSHOME is readonly (#9279)
Co-Authored-By: SteveL-MSFT <slee@microsoft.com>


Co-authored-by: Travis Plunk <travis.plunk@microsoft.com>
2019-04-04 23:01:01 -07:00
Klaudia Algiz 2df9aac811 Convert ShouldBeErrorId to Should -Throw -ErrorId in PowerShell tests (#6682)
Convert ShouldBeErrorId to Should -Throw -ErrorId in PowerShell tests.
Get rid of try { } catch { } formula to assert that errors were thrown.
Small fixes in tests to obey the new Pester -Parameter syntax.
2018-05-17 14:42:04 -07:00
Kevin Marquette acb52b3d9c Update tests in Microsoft.PowerShell.Security folder to use Pesterv4 syntax (#6256) 2018-03-23 10:41:14 -07:00
Steve Lee c1c5344a88 Update copyright and license headers (#6134)
Based on standard practices, we need to have a copyright and license notice at the top of each source file. Removed existing copyrights and updated/added copyright notices for .h, .cpp, .cs, .ps1, and .psm1 files.

Updated module manifests for consistency to have Author = "PowerShell" and Company = "Microsoft Corporation". Removed multiple line breaks.

Separate PR coming to update contribution document for new source files: #6140

Manually reviewed each change.

Fix #6073
2018-02-13 09:23:53 -08:00
Travis Plunk f67844e4cd Make 'AllSigned' execution policy require modules under $PSHome to be signed (#5511) 2017-11-28 17:34:37 -08:00
Steve Lee 7c9b188c13 Rename $IsOSX to $IsMacOS (#4757) 2017-09-07 10:34:40 -07:00
Ilya 409ab7443f Fix GetType() bad pattern and related issues in tests (#3134)
* Fix GetType() bad pattern and related issues in tests

$var.GetType() can raise an exception in tests so we should check $var
before make the call. A large part of the tests does not make this
check.
I start with searching ".GetType()" but discovered many related issues
in tests (reduntant and unneeded tests, "throw" bad pattens, bugs,
formattings (sorry!) and so on) - I had to fix them too.

* Fix after code review
* Second wave of migration GetType() -> BeOfType
Removed 'GetType().Name' patterns.
2017-02-15 16:40:51 -08:00
Jason Shirk 02b5f357a2 Remove trailing whitespace (#3001) 2017-01-16 13:31:14 -08:00
2xmax 1ccd155917 fixed some expected exception tests according to the template 611f7f9b77/docs/testing-guidelines/WritingPesterTests.md (L54) 2017-01-05 18:23:37 -08:00
Sergei Vorobev 9cc905dea4 Add verbose comment about the execution policy test
'-Scope LocalMachine is Settable, but overridden'
2016-09-29 16:06:42 -07:00
Sergei Vorobev 735bcca4d0 Allow ExecutionPolicy tests to throw specific type of error
Split LocalMachine test case into two separate tests:
- One without overriden policy (throws exception)
- One with overriden policy
2016-09-29 12:29:27 -07:00
Sergei Vorobev a1ee6d840d Make ExecutionPolicy.Tests.ps1 admin-aware 2016-09-29 12:29:27 -07:00
Mike Richmond adf6250175 Moving ExecutionPolicy tests to Microsoft.PowerShell.Security and refactoring test skipping for Windows. 2016-09-28 10:55:50 -07:00
James Truher 9e225ccae2 changes tags for tests
Start using tags CI, Feature, Scenario
2016-07-27 12:06:51 -07:00
Andrew Schwartzmeyer e6c037c666 Remove Platform.HasExecutionPolicy query
Also change Get-ExecutionPolicy to not throw, but to return
Unrestricted (which is the effect of the actual policy).
2016-07-14 17:34:12 -07:00
James Truher 1e1c4b7dc0 Restructure of pester test layout
This restructuring moves tests to a directory name which matches the module
in which the cmdlet resides which should improve the discoverability of a
specific test.
For tests which are not about cmdlets in a module, new directories have been
created to make those tests easier to find as well
2016-06-29 12:05:41 -07:00
Renamed from test/powershell/ExecutionPolicy.Tests.ps1 (Browse further)