diff --git a/.github/workflows/test_with_TestingHelper.yml b/.github/workflows/test_with_TestingHelper.yml new file mode 100644 index 0000000..30bda51 --- /dev/null +++ b/.github/workflows/test_with_TestingHelper.yml @@ -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 } + diff --git a/NotesHelper.psd1 b/NotesHelper.psd1 index 430476b..71d18b5 100644 --- a/NotesHelper.psd1 +++ b/NotesHelper.psd1 @@ -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 = @() diff --git a/Test/include/invokeCommand.mock.ps1 b/Test/include/invokeCommand.mock.ps1 index 6a8f8bb..6d52eb5 100644 --- a/Test/include/invokeCommand.mock.ps1 +++ b/Test/include/invokeCommand.mock.ps1 @@ -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' @@ -225,3 +222,5 @@ function Assert-MockFileNotfound{ throw "File not found or wrong case name. Expected[ $filename ] - Found[$( $file.name )]" } } + + diff --git a/Test/public/newNotes.test.ps1 b/Test/public/newNotes.test.ps1 index 83bd48a..975de15 100644 --- a/Test/public/newNotes.test.ps1 +++ b/Test/public/newNotes.test.ps1 @@ -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 -} \ No newline at end of file +} + +# ./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 \ No newline at end of file diff --git a/helper/invokeCommand.helper.ps1 b/helper/invokeCommand.helper.ps1 index bfe0526..7bbe0bb 100644 --- a/helper/invokeCommand.helper.ps1 +++ b/helper/invokeCommand.helper.ps1 @@ -38,4 +38,4 @@ function Reset-MyInvokeCommandAlias{ } # Reset all aliases for this module on each refresh -Reset-MyInvokeCommandAlias \ No newline at end of file +Reset-MyInvokeCommandAlias diff --git a/test.ps1 b/test.ps1 index d34447b..b477ff6 100644 --- a/test.ps1 +++ b/test.ps1 @@ -141,4 +141,4 @@ if($TestName){ Invoke-TestingHelper -TestName $TestName -ShowTestErrors:$ShowTestErrors } else { Invoke-TestingHelper -ShowTestErrors:$ShowTestErrors -} \ No newline at end of file +}