Getting Started with the Pytest Plugin for Infrahub
Blog post from OpsMill
The guide provides an in-depth walkthrough of using the pytest plugin in Infrahub to test GraphQL queries, Jinja2 templates, and Transformations with YAML-based tests, eliminating the need for Python coding. It emphasizes the importance of testing to catch potential issues early in the development process, preventing them from reaching production. The pytest framework in Infrahub allows for defining smoke, unit, and integration tests that validate the syntax and functionality of resources, ensuring they meet expected outcomes over time. The tutorial outlines setting up Infrahub using Docker, preparing a repository with necessary schemas and sample data, and writing tests to verify the behavior of Jinja2 Transformations. It also highlights the Infrahub Proposed Changes feature, akin to pull requests in Git, which facilitates code review and automated testing before integration, thereby enhancing the reliability of the development workflow.