Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build #6

Merged
merged 3 commits into from
Oct 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.github-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:

- name: Validate
run: Invoke-Build validate -ci $true
continue-on-error: true

- name: Report Test Results
uses: dorny/test-reporter@v1
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@
src/ValidateJson.nuspec
src/ValidateJson.psd1
dist
coverage.xml
coverage.xml
test\**\**
test\result\Pester-Test-Result.XML
testResults.xml
13 changes: 8 additions & 5 deletions ValidateJson.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,14 @@ task analyze {
task test {
if($ci){
New-Item -Path "$BuildRoot\test\" -Name "result" -ItemType "directory" -Force | out-null
Invoke-Pester -OutputFile "$BuildRoot\test\result\Pester-Test-Result.XML" `
-OutputFormat "JUnitXML"
# Invoke-Pester -CodeCoverage "$BuildRoot\src\$module_name.psm1" `
# -CodeCoverageOutputFile "$BuildRoot\test\result\Pester-Coverage.xml" `
# -CodeCoverageOutputFileFormat JaCoCo
$pesterConfig = New-PesterConfiguration -Hashtable @{
TestResult=@{
Enabled=$true
OutputPath="$BuildRoot\test\result\Pester-Test-Result.XML"
OutputFormat="JUnitXml"
}
}
Invoke-Pester -Configuration $pesterConfig
} else {
Invoke-Pester
}
Expand Down
24 changes: 12 additions & 12 deletions tests/Test-Json.Unit.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ Describe "Json ParameterSet" {

It "Handle pipeline input" {
$validJson | Test-Json | Should -BeTrue
$invalidJson | Test-Json 2> $null | Should -Not -BeTrue
$invalidJson | Test-Json -ErrorAction SilentlyContinue | Should -Not -BeTrue
}
It "Handle positional argument" {
Test-Json $validJson | Should -BeTrue
Test-Json $invalidJson 2> $null | Should -Not -BeTrue
Test-Json $invalidJson -ErrorAction SilentlyContinue | Should -Not -BeTrue
}
It "Handle explicit argument" {
Test-Json -Json $validJson | Should -BeTrue
Test-Json -Json $invalidJson 2> $null | Should -Not -BeTrue
Test-Json -Json $invalidJson -ErrorAction SilentlyContinue | Should -Not -BeTrue
}
}

Expand All @@ -33,21 +33,21 @@ Describe "Schema ParameterSet" {

It "Handle pipeline input" {
$validJson | Test-Json -Schema $schema | Should -BeTrue
$invalidJsonObject | Test-Json -Schema $schema -ErrorVariable errorvar 2> $null | Should -Not -BeTrue
$invalidJsonObject | Test-Json -Schema $schema -ErrorVariable errorvar -ErrorAction SilentlyContinue | Should -Not -BeTrue
$errorvar.FullyQualifiedErrorId | Should -Be "System.Exception,Test-Json"
$invalidJson | Test-Json -Schema $schema 2> $null | Should -Not -BeTrue
$invalidJson | Test-Json -Schema $schema -ErrorAction SilentlyContinue | Should -Not -BeTrue
}
It "Handle positional argument" {
Test-Json $validJson -Schema $schema | Should -BeTrue
Test-Json $invalidJsonObject -Schema $schema -ErrorVariable errorvar 2> $null | Should -Not -BeTrue
Test-Json $invalidJsonObject -Schema $schema -ErrorVariable errorvar -ErrorAction SilentlyContinue | Should -Not -BeTrue
$errorvar.FullyQualifiedErrorId | Should -Be "System.Exception,Test-Json"
Test-Json $invalidJson -Schema $schema 2> $null | Should -Not -BeTrue
Test-Json $invalidJson -Schema $schema -ErrorAction SilentlyContinue | Should -Not -BeTrue
}
It "Handle explicit argument" {
Test-Json -Json $validJson -Schema $schema | Should -BeTrue
Test-Json -Json $invalidJsonObject -Schema $schema -ErrorVariable errorvar 2> $null | Should -Not -BeTrue
Test-Json -Json $invalidJsonObject -Schema $schema -ErrorVariable errorvar -ErrorAction SilentlyContinue | Should -Not -BeTrue
$errorvar.FullyQualifiedErrorId | Should -Be "System.Exception,Test-Json"
Test-Json -Json $invalidJson -Schema $schema 2> $null | Should -Not -BeTrue
Test-Json -Json $invalidJson -Schema $schema -ErrorAction SilentlyContinue | Should -Not -BeTrue
}
}

Expand All @@ -63,14 +63,14 @@ Describe "File ParameterSet" {

It "Handle pipeline input" {
$validJson | Test-Json -SchemaFile $schemaPath | Should -BeTrue
$invalidJson | Test-Json -SchemaFile $schemaPath 2> $null | Should -Not -BeTrue
$invalidJson | Test-Json -SchemaFile $schemaPath -ErrorAction SilentlyContinue | Should -Not -BeTrue
}
It "Handle positional argument" {
Test-Json $validJson -SchemaFile $schemaPath | Should -BeTrue
Test-Json $invalidJson -SchemaFile $schemaPath 2> $null | Should -Not -BeTrue
Test-Json $invalidJson -SchemaFile $schemaPath -ErrorAction SilentlyContinue | Should -Not -BeTrue
}
It "Handle explicit argument" {
Test-Json -Json $validJson -SchemaFile $schemaPath | Should -BeTrue
Test-Json -Json $invalidJson -SchemaFile $schemaPath 2> $null | Should -Not -BeTrue
Test-Json -Json $invalidJson -SchemaFile $schemaPath -ErrorAction SilentlyContinue | Should -Not -BeTrue
}
}
7 changes: 5 additions & 2 deletions tools/dev-init.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Install-Module InvokeBuild,PSScriptAnalyzer,platyPS -Scope CurrentUser -Force
Install-Module Pester -Scope CurrentUser -MinimumVersion "5.0.0"
Install-Module "InvokeBuild","PSScriptAnalyzer","platyPS" -Scope CurrentUser -Force
Install-Module "Pester" -Scope CurrentUser -MinimumVersion "5.0.0" -Force

Write-host "Module Versions are"
Get-Module -ListAvailable "InvokeBuild","PSScriptAnalyzer","platyPS","Pester" | Select-Object Name,Version

if($(winget list --id Microsoft.NuGet --disable-interactivity --accept-source-agreements|out-string) -like '*No installed package found*') {
winget install -e --id Microsoft.NuGet --disable-interactivity --accept-source-agreements
Expand Down
Loading