Skip to content

Commit

Permalink
Rename Test-PSRule to Test-PSRuleTarget #57 (#58)
Browse files Browse the repository at this point in the history
- Rename Test-PSRule to Test-PSRuleTarget #57
  • Loading branch information
BernieWhite authored Jan 14, 2019
1 parent ed781c4 commit 9157b5f
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 22 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

- Fix Get-PSRule generates exception when no .rule.ps1 scripts exist in path [#53](https://github.com/BernieWhite/PSRule/issues/53)
- Fix LocalizedData.PathNotFound warning when no .rule.ps1 scripts exist in path [#54](https://github.com/BernieWhite/PSRule/issues/54)
- **Breaking change** - Renamed `Test-PSRule` cmdlet to `Test-PSRuleTarget` which aligns more closely to the verb-noun naming standard [#57](https://github.com/BernieWhite/PSRule/issues/57)

## v0.2.0-B19010501 (pre-release)
## v0.2.0-B190105 (pre-release)

- Allow objects to be suppressed by _TargetName_ for individual rules [#13](https://github.com/BernieWhite/PSRule/issues/13)
- Allow binding of _TargetName_ to custom property [#44](https://github.com/BernieWhite/PSRule/issues/44)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ The following commands exist in the `PSRule` module:
- [Invoke-PSRule](docs/commands/PSRule/en-US/Invoke-PSRule.md)
- [Get-PSRule](docs/commands/PSRule/en-US/Get-PSRule.md)
- [New-PSRuleOption](docs/commands/PSRule/en-US/New-PSRuleOption.md)
- [Test-PSRule](docs/commands/PSRule/en-US/Test-PSRule.md)
- [Test-PSRuleTarget](docs/commands/PSRule/en-US/Test-PSRuleTarget.md)

### Concepts

Expand Down
2 changes: 1 addition & 1 deletion docs/commands/PSRule/en-US/Invoke-PSRule.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,4 +253,4 @@ When you use the `-As Summary`. Otherwise, it returns a `RuleRecord` object.
## RELATED LINKS

[Get-PSRule](Get-PSRule.md)
[Test-PSRule](Test-PSRule.md)
[Test-PSRuleTarget](Test-PSRuleTarget.md)
2 changes: 1 addition & 1 deletion docs/commands/PSRule/en-US/PSRule.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ Evaluate pipeline objects against matching rules.

Create options to configure PSRule execution.

### [Test-PSRule](Test-PSRule.md)
### [Test-PSRuleTarget](Test-PSRuleTarget.md)

Evaluate pipeline objects against matching rules.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
external help file: PSRule-help.xml
Module Name: PSRule
online version: https://github.com/BernieWhite/PSRule/blob/master/docs/commands/PSRule/en-US/Test-PSRule.md
online version: https://github.com/BernieWhite/PSRule/blob/master/docs/commands/PSRule/en-US/Test-PSRuleTarget.md
schema: 2.0.0
---

# Test-PSRule
# Test-PSRuleTarget

## SYNOPSIS

Expand All @@ -14,7 +14,7 @@ Pass or fail pipeline objects against matching rules.
## SYNTAX

```text
Test-PSRule [[-Path] <String[]>] [-Name <String[]>] [-Tag <Hashtable>] -InputObject <PSObject>
Test-PSRuleTarget [[-Path] <String[]>] [-Name <String[]>] [-Tag <Hashtable>] -InputObject <PSObject>
[-Option <PSRuleOption>] [<CommonParameters>]
```

Expand All @@ -36,7 +36,7 @@ PSRule uses the following logic to determine overall pass or fail for an object:
### Example 1

```powershell
@{ Name = 'Item 1' } | Test-PSRule;
@{ Name = 'Item 1' } | Test-PSRuleTarget;
```

Evaluate a simple hashtable on the pipeline against rules loaded from the current working path.
Expand Down
2 changes: 1 addition & 1 deletion src/PSRule/PSRule.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ FormatsToProcess = @('PSRule.Format.ps1xml')
FunctionsToExport = @(
'Rule'
'Invoke-PSRule'
'Test-PSRule'
'Test-PSRuleTarget'
'Get-PSRule'
'New-PSRuleOption'
'AllOf'
Expand Down
8 changes: 4 additions & 4 deletions src/PSRule/PSRule.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ function Invoke-PSRule {
}

# .ExternalHelp PSRule-Help.xml
function Test-PSRule {
function Test-PSRuleTarget {
[CmdletBinding()]
[OutputType([System.Boolean])]
param (
Expand All @@ -169,7 +169,7 @@ function Test-PSRule {
)

begin {
Write-Verbose -Message "[Test-PSRule] BEGIN::";
Write-Verbose -Message "[Test-PSRuleTarget] BEGIN::";

# Get parameter options, which will override options from other sources
$optionParams = @{ };
Expand Down Expand Up @@ -222,7 +222,7 @@ function Test-PSRule {
if ($Null -ne $pipeline) {
$pipeline.Dispose();
}
Write-Verbose -Message "[Test-PSRule] END::";
Write-Verbose -Message "[Test-PSRuleTarget] END::";
}
}

Expand Down Expand Up @@ -594,6 +594,6 @@ InitEditorServices;
# Export module
#

Export-ModuleMember -Function 'Rule','Invoke-PSRule','Test-PSRule','Get-PSRule','New-PSRuleOption';
Export-ModuleMember -Function 'Rule','Invoke-PSRule','Test-PSRuleTarget','Get-PSRule','New-PSRuleOption';

# EOM
18 changes: 9 additions & 9 deletions tests/PSRule.Tests/PSRule.Common.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -325,32 +325,32 @@ Describe 'Invoke-PSRule' {

#endregion Invoke-PSRule

#region Test-PSRule
#region Test-PSRuleTarget

Describe 'Test-PSRule' {
Describe 'Test-PSRuleTarget' {
Context 'With defaults' {
$testObject = [PSCustomObject]@{
Name = "TestObject1"
}

It 'Returns boolean' {
# Check passing rule
$result = $testObject | Test-PSRule -Path (Join-Path -Path $here -ChildPath 'FromFile.Rule.ps1') -Name 'FromFile1';
$result = $testObject | Test-PSRuleTarget -Path (Join-Path -Path $here -ChildPath 'FromFile.Rule.ps1') -Name 'FromFile1';
$result | Should -Not -BeNullOrEmpty;
$result | Should -BeOfType System.Boolean;
$result | Should -Be $True;

# Check result with one failing rule
$option = @{ 'Execution.InconclusiveWarning' = $False };
$result = $testObject | Test-PSRule -Path (Join-Path -Path $here -ChildPath 'FromFile.Rule.ps1') -Name 'FromFile1', 'FromFile2', 'FromFile3' -Option $option;
$result = $testObject | Test-PSRuleTarget -Path (Join-Path -Path $here -ChildPath 'FromFile.Rule.ps1') -Name 'FromFile1', 'FromFile2', 'FromFile3' -Option $option;
$result | Should -Not -BeNullOrEmpty;
$result | Should -BeOfType System.Boolean;
$result | Should -Be $False;
}

It 'Returns warnings on inconclusive' {
# Check result with an inconculsive rule
$result = $testObject | Test-PSRule -Path (Join-Path -Path $here -ChildPath 'FromFile.Rule.ps1') -Name 'FromFile3' -WarningVariable outWarnings -WarningAction SilentlyContinue;
$result = $testObject | Test-PSRuleTarget -Path (Join-Path -Path $here -ChildPath 'FromFile.Rule.ps1') -Name 'FromFile3' -WarningVariable outWarnings -WarningAction SilentlyContinue;
$result | Should -Not -BeNullOrEmpty;
$result | Should -BeOfType System.Boolean;
$result | Should -Be $False;
Expand All @@ -359,7 +359,7 @@ Describe 'Test-PSRule' {

It 'Returns warnings on no rules' {
# Check result with no matching rules
$result = $testObject | Test-PSRule -Path (Join-Path -Path $here -ChildPath 'FromFile.Rule.ps1') -Name 'NotARule' -WarningVariable outWarnings -WarningAction SilentlyContinue;
$result = $testObject | Test-PSRuleTarget -Path (Join-Path -Path $here -ChildPath 'FromFile.Rule.ps1') -Name 'NotARule' -WarningVariable outWarnings -WarningAction SilentlyContinue;
$result | Should -BeNullOrEmpty;
$outWarnings | Should -Be 'Could not find a matching rule. Please check that Path, Name and Tag parameters are correct.';
}
Expand All @@ -369,7 +369,7 @@ Describe 'Test-PSRule' {
if (!(Test-Path -Path $emptyPath)) {
$Null = New-Item -Path $emptyPath -ItemType Directory -Force;
}
$Null = $testObject | Test-PSRule -Path $emptyPath -WarningVariable outWarnings -WarningAction SilentlyContinue;
$Null = $testObject | Test-PSRuleTarget -Path $emptyPath -WarningVariable outWarnings -WarningAction SilentlyContinue;
$warningMessages = $outwarnings.ToArray();
$warningMessages.Length | Should -Be 1;
$warningMessages[0] | Should -BeOfType [System.Management.Automation.WarningRecord];
Expand All @@ -378,7 +378,7 @@ Describe 'Test-PSRule' {

It 'Returns warnings on no processed rules' {
# Check result with no rules matching precondition
$result = $testObject | Test-PSRule -Path (Join-Path -Path $here -ChildPath 'FromFile.Rule.ps1') -Name 'WithPreconditionFalse' -WarningVariable outWarnings -WarningAction SilentlyContinue;
$result = $testObject | Test-PSRuleTarget -Path (Join-Path -Path $here -ChildPath 'FromFile.Rule.ps1') -Name 'WithPreconditionFalse' -WarningVariable outWarnings -WarningAction SilentlyContinue;
$result | Should -Not -BeNullOrEmpty;
$result | Should -BeOfType System.Boolean;
$result | Should -Be $True;
Expand All @@ -387,7 +387,7 @@ Describe 'Test-PSRule' {
}
}

#endregion Test-PSRule
#endregion Test-PSRuleTarget

#region Get-PSRule

Expand Down

0 comments on commit 9157b5f

Please sign in to comment.