14 Maintaining your code
This chapter covers
- Making changes to older functions without breaking exiting automations
- Using automated testing to verify that code changes do not break existing functionality
- Automating unit and integration tests with GitHub workflows
Throughout this book, I have stressed the importance of building code that you can easily maintain and share. You have seen how to accomplish this through the use of functions and modules. Then in chapter 12, you saw how to use GitHub to store your code and control the changes to it through pull requests. And in chapter 13, you saw how to build unit and integration tests to ensure that your code functions as expected. Now, in this chapter, you will see how to bring this all together.
In chapter 11, you created the module PoshAutomator and stored it in GitHub. This module contains the function Get-SystemInfo, which returns information about the local computer. However, the focus of the chapter was more around GitHub and source control than the code itself. Therefore Get-SystemInfo is a fairly basic function. It uses the Get-CimInstance cmdlet to gather data, which only works on Windows machines. So, in this chapter, we are going to expand it to include the same information for Linux based machines.