Skip to content
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
46 changes: 46 additions & 0 deletions .github/workflows/test_with_TestingHelper.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# This is a workflow to test you PowerShell module with TestingHelper
# https://github.com/rulasg/DemoPsModule/blob/main/.github/workflows/test_with_TestingHelper.yml

name: Test with TestingHelper

# Controls when the workflow will run
on:

# Run as check on pull request
pull_request:

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

permissions:
# To run test we only need to read the repository
contents: read

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
test:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3

# Runs a single command using the runners shell
- name: Run test.ps1
shell: pwsh
run: |
$result = ./test.ps1 -ShowTestErrors
$result

# Allow Not Implemented and Skipped tests to pass
$passed = $result.Tests -eq $result.Pass + $result.NotImplemented + $result.Skipped
# $passed = $result.Tests -eq $result.Pass

if($passed)
{ "All test passed" | Write-Verbose -verbose ; exit 0 }
else
{ "Not all tests passed" | Write-Verbose -verbose ; exit 1 }

2 changes: 1 addition & 1 deletion NotesHelper.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Copyright = '(c) rulasg. All rights reserved.'
# ProcessorArchitecture = ''

# Modules that must be imported into the global environment prior to importing this module
# RequiredModules = @()
RequiredModules = @(@{ModuleName="InvokeHelper"; ModuleVersion="1.2.4"})

# Assemblies that must be loaded prior to importing this module
# RequiredAssemblies = @()
Expand Down
5 changes: 2 additions & 3 deletions Test/include/invokeCommand.mock.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
$MODULE_ROOT_PATH = $PSScriptRoot | Split-Path -Parent | Split-Path -Parent
$MODULE_NAME = (Get-ChildItem -Path $MODULE_ROOT_PATH -Filter *.psd1 | Select-Object -First 1).BaseName

if(-not $MODULE_NAME){ throw "Missing MODULE_NAME varaible initialization. Check for module.helerp.ps1 file." }
if(-not $MODULE_ROOT_PATH){ throw "Missing MODULE_ROOT_PATH varaible initialization. Check for module.helerp.ps1 file." }

$testRootPath = $MODULE_ROOT_PATH | Join-Path -ChildPath 'Test'
$MOCK_PATH = $testRootPath | Join-Path -ChildPath 'private' -AdditionalChildPath 'mocks'

Expand Down Expand Up @@ -225,3 +222,5 @@ function Assert-MockFileNotfound{
throw "File not found or wrong case name. Expected[ $filename ] - Found[$( $file.name )]"
}
}


9 changes: 7 additions & 2 deletions Test/public/newNotes.test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,16 @@ function Test_NewNotesToday_Failing{
MockCallToString 'echo $NOTES_ROOT' -OutString "./TestNotesRoot"

New-TestingFolder -Path "./TestNotesRoot/howto"
$today = (Get-Date).ToString("yyMMdd")

# Act
$result = note howto "someting that may be useful" -NoOpen

$expectedPath = './TestNotesRoot/howto/250720-howto-someting_that_may_be_useful/250720-howto-someting_that_may_be_useful.md'
$expectedPath = "./TestNotesRoot/howto/$today-howto-someting_that_may_be_useful/$today-howto-someting_that_may_be_useful.md"

Assert-AreEqualPath -Expected $expectedPath -Presented $result
}
}

# ./TestNotesRoot/howto/250720-howto-someting_that_may_be_useful/250720-howto-someting_that_may_be_useful.md ]
# ./TestNotesRoot/howto/250728-howto-someting_that_may_be_useful/250728-howto-someting_that_may_be_useful.md ]
# [ /tmp/Posh_Testing_250728_87d8dc/TestRunFolder/Test_NewNotesToday_Failing
2 changes: 1 addition & 1 deletion helper/invokeCommand.helper.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ function Reset-MyInvokeCommandAlias{
}

# Reset all aliases for this module on each refresh
Reset-MyInvokeCommandAlias
Reset-MyInvokeCommandAlias
2 changes: 1 addition & 1 deletion test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,4 @@ if($TestName){
Invoke-TestingHelper -TestName $TestName -ShowTestErrors:$ShowTestErrors
} else {
Invoke-TestingHelper -ShowTestErrors:$ShowTestErrors
}
}