I made a thing! A thing in PowerShell!
I’m not really sure how to make a module in PowerShell, but I made functions to do these epoch conversions and put them in a .psm1
file. Don’t know if there’s more to it or not.
Naturally, I wanted to write tests as I worked. I discovered that there is no testing framework in PowerShell, but there’s a terrific third-party framework called Pester. Since PowerShell on Linux is so new, I had no idea if it was going to work. I was pleased when it installed without issue, but at first it didn’t appear to work. Turns out it was assuming I had a $env:TEMP
defined, but I had not. I took a guess and just set it to /tmp
$env:TEMP = '/tmp'
and then all was well! When you are in the directory where your module and tests are, you can import your module with
Import-Module ./Epochs
and then run your tests with
Invoke-Pester
That is, if we’ve named everything the way Pester expects, we just take all the defaults!
I learned the hard way that PowerShell won’t re-import a module it has already imported, by default. Making changes to Epochs.psm1
and then doing
Import-Module ./Epochs Invoke-Pester
made me think my tests were still passing with my code changes, but it hadn’t actually reloaded my module. You have to -force
it
Import-Module ./Epochs -force Invoke-Pester
I’m still stumbling around when it comes to PowerShell, but Pester makes me feel more at home!