Search code examples
windows-installerchef-infraserverspec

What are some goals or best practices when testing a package install with ServerSpec?


So, I've successfully used Vagrant and Chef to install an MSI onto a Windows guest VM. Woot! Then, I wrote a few tests with ServerSpec that check that after the MSI was installed, files got put into their proper places and things like that.

My question is: What sort of goals should I have when it comes to acceptance testing an install of a package like that? Should I be checking for specific files? But what if there are lots of files? Or is checking for each file too low-level? Too close to the implementation details? What level should I be at when writing acceptance tests for a successful package install?


Solution

  • I use test driven development, so I generally have one test per resource in my recipe. I write the tests first. So if my basic design is:

    1. I need to install xxx
    2. I need to fix the config file for xxx
    3. I need to start the xxx service

    Then I'd write three tests in my serverspec.

    1. check with package to ensure the install happend
    2. check with file to ensure the config file is present, with the correct mode, owner, group, and content
    3. check with service that the service is running.

    Then I'd write my recipe using the package, file or template, and service resources.