Giter Site home page Giter Site logo

Comments (8)

vexx32 avatar vexx32 commented on June 15, 2024

Ah, yep, looks like we need to be making sure we load the Get-Blank function and its aliases into the new runspace, which it seems we're not doing at the moment. Definitely seems like something we need to look into here.

from pskoans.

DEberhardt avatar DEberhardt commented on June 15, 2024

in the same Kaon, the following I cannot overcome:

Cannot process argument transformation on parameter 'ExceptionType'. Cannot
convert the "ItemNotFoundException" value of type "System.String" to type
"System.Type".

    Please meditate on the following code:

× It "allows you to copy, rename, or delete files"
at <ScriptBlock>, C:\Users\David\PSKoans\Cmdlets 1\AboutPSProviders.Koans.ps1:
line 174
174:         { Get-Item -Path $FilePath -ErrorAction Stop } | Should -Throw
-ExceptionType 'ItemNotFoundException'

Line 174 reads:
{ Get-Item -Path $FilePath -ErrorAction Stop } | Should -Throw -ExceptionType 'ItemNotFoundException'

ItemNotFoundException is what my error returns:

❯ $Error[1].CategoryInfo


Category   : ObjectNotFound
Activity   : Get-Item
Reason     : ItemNotFoundException
TargetName : C:\Users\David\AppData\Local\Temp\TESTNAME.tmp
TargetType : String

so don't know what is actually wrong here...

from pskoans.

vexx32 avatar vexx32 commented on June 15, 2024

When handling types, you will often need to qualify them by a namespace name if they're not in the default set of namespaces. If you grab $error[1].Exception.GetType().Fullname you'll see the full type name you can use for that assertion. 🙂

from pskoans.

DEberhardt avatar DEberhardt commented on June 15, 2024

The main error here leads to:

Expected 123, but got $null

The respective Test is the following:

        It 'allows you to remove variables' {
            $Test = 123

            123 | Should -Be $Test

            Remove-Item -Path 'Variable:\Test'
            $null | Should -Be $Test
            { Get-Item -Path 'Variable:\Test' -ErrorAction Stop } | Should -Throw -ExceptionType PathNotFound
        }

I tried to overcome this with changing line 261 to:
Remove-Item -Path 'Variable:\Test' -Force
but this did not work

Commenting out Line 261 will lead to another error on the next line.
Don't know if I am doing something wrong here, but this is what I get:

Cannot process argument transformation on parameter 'ExceptionType'. Cannot
convert the "PathNotFound" value of type "System.String" to type "System.Type".

(same as above)

from pskoans.

DEberhardt avatar DEberhardt commented on June 15, 2024

further on, I get a similar thing:

        It 'allows you to set variable options' {
            Set-Variable -Name 'Test' -Value 'TEST'

            $Var = Get-Item -Path 'Variable:\Test'
            $Var.Options = [System.Management.Automation.ScopedItemOptions]::ReadOnly

            'TEST' | Should -Be $Var
            { Remove-Item -Path 'Variable:\Test' -ErrorAction Stop } | Should -Throw -ExceptionType PathNotFound
        }

which gives me:

Expected System.Management.Automation.PSVariable, but got 'TEST'.

    Please meditate on the following code:

× It "allows you to set variable options"
at <ScriptBlock>, C:\Users\David\PSKoans\Cmdlets 1\AboutPSProviders.Koans.ps1:
line 280
280:             'TEST' | Should -Be $Var

the premise is to insert a string '____' which I presume to be the value of the variable
should this be 'TEST' | Should -Be $Var.Value? (which works)

Line 281 again fails because the variable cannot be removed

from pskoans.

DEberhardt avatar DEberhardt commented on June 15, 2024

When handling types, you will often need to qualify them by a namespace name if they're not in the default set of namespaces. If you grab $error[1].Exception.GetType().Fullname you'll see the full type name you can use for that assertion. 🙂

Thank you. Didn't know you can drill down that far into Error-messages... I am usually content handling the $_.Exception.Message in catch blocks :)

from pskoans.

FH-Inway avatar FH-Inway commented on June 15, 2024

Regarding #455 (comment), I got the same issue with variable $Test with value 123 that should be $null after the variable was removed.
It works when I do it in the console.
When I tried to do Remove-Item -Path 'Variable:\*' -Force, I got a bunch of error messages, one of them saying

Cannot remove variable Test because the variable has been optimized and is not removable. Try using the Remove-Variable cmdlet (without any aliases), or dot-sourcing the command that you are using to remove the variable.

I added the Remove-Variable call, which resolved the issue, but is probably not the intended result of the Koan.

Seems related to #435

from pskoans.

FH-Inway avatar FH-Inway commented on June 15, 2024

Regarding #455 (comment), I'm also confused why It 'allows you to set variable options' requires System.Management.Automation.PSVariable instead of 'TEST' as the solution for the '____' | Should -Be $Var check.

from pskoans.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.