Pester test on Appveyor not importing my module

This topic contains 8 replies, has 3 voices, and was last updated by Profile photo of Martin9700 Martin9700 5 months, 3 weeks ago.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #37470
    Profile photo of Martin9700
    Martin9700
    Participant

    Putting together my first appveyor/pester test for a module and failing miserably. Integration is all working, but when I do an Import-Module in my pester test it simply doesn't import the functions. It *says* it is but nothing gets imported. I've tried Get-Command -Module TestSQL after the import.

    Anyone seen anything like this? Not sure what information I can provide but happy to post the pester scripts/yml if needed.

    #37471
    Profile photo of Dave Wyatt
    Dave Wyatt
    Moderator

    Will need to see the code, not sure what's going on based on your description so far.

    #37472
    Profile photo of Dave Wyatt
    Dave Wyatt
    Moderator

    Found it on GitHub. 🙂 Two things jumped out at me:

    https://github.com/martin9700/TestSQL/blob/master/TestSQL.psd1#L12

    You've got RootModule = 'TestSQL' ; this might need to say 'TestSQL.psm1'. I've never tried it without an extension before.

    In your Tests.ps1 file, you're using an absolute path for the import: https://github.com/martin9700/TestSQL/blob/master/Source/Test/Invoke-SQLQuery.tests.ps1#L3

    Personally, I would always use a relative path here:

    Import-Module "$PSScriptRoot\..\..\TestSQL.psd1"
    

    But since your appveyor job seems to be set up to clone to the same absolute path that's mentioned in the Tests.ps1 script, that may be fine.

    #37474
    Profile photo of Martin9700
    Martin9700
    Participant

    Hi Dave, I've always done just the Folder name there. I should note that this all works fine on my PC, so it's definitely a appveyor thing. I do have explicit paths in there right now as I'm just getting this off the ground for now, but I have big plans (bwahahaha)

    Anyway, the module looks like it's loading, but when I do Get-Command -Module TestSQL I get nothing (see below). G1, G2 and G3 are all locators where I do the Get-Command right after.

    #37475
    Profile photo of Martin9700
    Martin9700
    Participant

    That said, will give it a try. Syncing now, and build is queued. Have to run out to dinner (argh!) so I'll update later tonight on pass/fail.

    #37476
    Profile photo of Martin9700
    Martin9700
    Participant

    Just an update. Same problem as above. Module looks like it loads, but then none of the functions are there.

    #37487
    Profile photo of Martin9700
    Martin9700
    Participant

    Wanted to leave a last update. Loading the module using just the folder name still fails. Funny enough, this happened before when RootModule didn't have the name of the folder in it on an earlier version of my module creation script.

    That data is there now and still won't load in appveyor, however, I did get the functions to load if I specified the PSM1 extension. I suspect some kind of issue with the manifest file, but it works fine on a regular PC (hah, on "my" PC, famous last words) and this seems to be simply an Appveyor problem.

    So, now I have to get SQL properly configured so the module can be tested. Why did I pick this as my first Appveyor project?!

    #37491
    Profile photo of TomBaker
    TomBaker
    Participant

    Try changing functions to export in your manifest to an array of strings rather than one big string.

    #37502
    Profile photo of Martin9700
    Martin9700
    Participant

    Hey Tom, I thought I had fixed that! Was using a hashtable and the .Keys property but it's interested how New-ModuleManifest and Update-ModuleManifest treat that differently! I originally had something else in mind which is why I used a hashtable in this instance but that requirement went away so I think I'll just switch over to an Array.List instead and that should resolve that problem.

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.