poshbotio / PoshBot

Powershell-based bot framework
MIT License
536 stars 108 forks source link

ScriptsToProcess -> PoshBotAttribute.ps1 not found #158

Closed Stephanevg closed 4 years ago

Stephanevg commented 5 years ago

Hi, I was testing my cmdlet write-CUPesterTEsts to generate automatically pester tests for a module.

The first test I launched gave this result back:

Executing script C:\Users\taavast3\OneDrive\Repo\Projects\OpenSource\PoshBot\GeneratedTests\AccessFilter.Tests.Ps1
WARNING: Did not find config file C:\Users\taavast3\AppData\Local\Temp\taavast3-U279610-PSSlack.xml,
attempting to create
  [-] Error occurred in test script 'C:\Users\taavast3\OneDrive\Repo\Projects\OpenSource\PoshBot\GeneratedTests\AccessFilter.Tests.Ps1' 9.41s
    ArgumentException: The member 'ScriptsToProcess' in the module manifest is not valid: Cannot find path 'C:\Users\taavast3\OneDrive\Repo\Projects\OpenSource\PoshBot\PoshBot\PoshBotAttribute.ps1' because it does not exist.. Verify that a valid value is specified for this field in the 'C:\Users\taavast3\OneDrive\Repo\Projects\OpenSource\PoshBot\PoshBot\PoshBot.psd1' file.
    at <ScriptBlock>, \\ss002207\TAAVAST3$\Documents\WindowsPowerShell\Modules\Pester\4.4.3\Pester.psm1: line 847
    at Invoke-Pester<End>, \\ss002207\TAAVAST3$\Documents\WindowsPowerShell\Modules\Pester\4.4.3\Pester.psm1: line 862

In other words, It tries to process that PoshBotAttribute.ps1 file through the ScriptsToProcessattribute, but that file is not there. (And is not in any other folder of the repo btw).

Is this a mistake? Is it safe to comment this line in the module manifest? Or do we need to have that PoshBotAttribute.ps1 to be present? If yes, what should it contain?

Cheers

edit

This is the pester test I used, which was automatically generated:

using module C:\Users\taavast3\OneDrive\Repo\Projects\OpenSource\PoshBot\PoshBot

InModuleScope -ModuleName PoshBot -ScriptBlock {

    Describe '[AccessFilter]-[Constructors]' {

    }# end of Describe block
    Describe '[AccessFilter]-[Methods]' {

        #Public Method
        It '[AccessFilter] --> Authorize($PermissionName) : [CommandAuthorizationResult] - should Not Throw' {

            # -- Arrange

            [string]$PermissionName = ''

            # -- Act

            $Instance = [AccessFilter]::New()

            # -- Assert

            {$Instance.Authorize($PermissionName)} | Should Not Throw

        } #End It Block

        #Public Method
        It '[AccessFilter] --> Authorize($PermissionName) : [CommandAuthorizationResult] - should return type [CommandAuthorizationResult]' {

            # -- Arrange
            [string]$PermissionName = ''

            # -- Act

            $Instance = [AccessFilter]::New()
            # -- Assert

            ($Instance.Authorize($PermissionName)).GetType().Name | should be CommandAuthorizationResult

        } #End It Block

        #Public Method
        It '[AccessFilter] --> AddPermission($Permission) : [void] - should Not Throw' {

            # -- Arrange

            [Permission]$Permission = ''

            # -- Act

            $Instance = [AccessFilter]::New()

            # -- Assert

            {$Instance.AddPermission($Permission)} | Should Not Throw

        } #End It Block

        #Public Method
        It '[AccessFilter] --> AddPermission($Permission) Should not return anything (voided)' {

            # -- Arrange
            [Permission]$Permission = ''

            # -- Act

            $Instance = [AccessFilter]::New()
            # -- Assert

            $Instance.AddPermission($Permission)| should be $null

        } #End It Block

        #Public Method
        It '[AccessFilter] --> RemovePermission($Permission) : [void] - should Not Throw' {

            # -- Arrange

            [Permission]$Permission = ''

            # -- Act

            $Instance = [AccessFilter]::New()

            # -- Assert

            {$Instance.RemovePermission($Permission)} | Should Not Throw

        } #End It Block

        #Public Method
        It '[AccessFilter] --> RemovePermission($Permission) Should not return anything (voided)' {

            # -- Arrange
            [Permission]$Permission = ''

            # -- Act

            $Instance = [AccessFilter]::New()
            # -- Assert

            $Instance.RemovePermission($Permission)| should be $null

        } #End It Block

    }#EndDescribeBlock

}#End InModuleScope
devblackops commented 5 years ago

Hi @Stephanevg. PoshBotAttribute.ps1 should reside at the root of the module along side the PSD1 and PSM1. In the source, it lives under Classes.

https://github.com/poshbotio/PoshBot/blob/master/PoshBot/Classes/PoshBotAttribute.ps1

If you run build task below, it will copy that file to the root of the built module under the out/PoshBot/<version> folder. This file is critical as it contains the custom attributes you attach to functions or parameters to control how PoshBot handles the commands.

./build.ps1 -task build
stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Stephanevg commented 4 years ago

Thanks for the feedback @devblackops I just wanted to report this one - In case you were not aware of it.

Perhaps it would make sense to write this one done somewhere (Perhaps directly on the readme?) as all I did was a clone from you repo, and than I was kind of blocked. (Was trying to generate tests fro your module).