Comments (8)
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.
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.
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.
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.
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.
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.
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.
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)
- Problem in koan AboutModules
- Koan AboutSelectObject has undesired error
- Problem with different PowerShell versions in koan AboutSortObject
- Topics solved before starting in koan AboutComparison
- Show-Karma failed on relatively fresh installation HOT 6
- AboutCmdletVerbs.Koans.ps1 - Forward slash in $Filename results in wrong string comparison at the end HOT 2
- AboutGetMember.Koans.ps1 does not return correct result HOT 4
- Recursion on $home throws UnauthorizedAccessException - Local Issue HOT 4
- Enumeration time is quite long the more you progress HOT 2
- AboutRedirection misses some spaces in output?
- Get-Unique is used on unsorted collections
- AboutAssignmentAndArithmetic: ExpectedMessage and implicit character ranges in Pester 5 HOT 1
- Show-Karma fails after repo-based installation HOT 2
- AboutBitwiseOperations - Error in description? HOT 1
- Show-Karma -Contemplate breaks after Classes HOT 12
- VScode error: Could not find the module 'PSKoans'. commands typed in console window work fine. HOT 2
- About XML addresses $RootElement but that changes with the next test HOT 1
- Regex: $matches[0] is empty within "It does not need to match the entire string" and "It is not just an array of text"
- AboutNumbers wrong types HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pskoans.