Skip to main content

Tests configuration file

The tests configuration file allows you to define multiple tests for Infrahub resources such as Jinja2 transforms, Python transforms, checks and GraphQL queries.

The file should be formatted as a YAML file, have a filename prefixed with test_ like test_all.yml and should be stored somewhere in the repository.

info

See this topic for more details on the available repository configuration options

Version​

Key: version
Type: string
Mandatory: ❌
Default: 1.0

Infrahub Tests​

Key: infrahub_tests
Type: array of tests
Mandatory: ✅

Each test must define a kind of resource to test as well as the name of the resource which must be a valid resource name matching to the repository configuration.

Key: resource
Type: string
Mandatory: ✅
Possible value: Check Jinja2Transform PythonTransform GraphQLQuery

Key: resource_name
Type: string
Mandatory: ✅

An optional outcome value for the test can be specified.

Key: expect
Type: string
Mandatory: ❌
Default: PASS
Possible value: PASS FAIL

Each test must then defined a specification, using the spec key, which will set properties for the test itself.

Key: spec
Type: dictionary
Mandatory: ✅

Depending on the test, the dictionary spec may contain the following keys.

note

When a test has an input or an output property, the value of these can be path to JSON (with the .json suffix), YAML (with the .yaml or .yml suffixes) or plain text files.

Test kind check-smoke​

SpecTypeDescriptionMandatoryDefault
kindstringStatic value check-smoke✅

Test kind check-unit-process​

SpecTypeDescriptionMandatoryDefault
directorystringPath to the directory where the input and output files are located❌
inputstringPath to the file with the input data for the test, can be a relative path from the configuration file or from the directory.❌input.json
outputstringPath to the file with the expected output for the test, can be a relative path from the configuration file or from the directory.❌
kindstringStatic value check-unit-process✅

Test kind check-integration​

SpecTypeDescriptionMandatoryDefault
directorystringPath to the directory where the input and output files are located❌
inputstringPath to the file with the input data for the test, can be a relative path from the configuration file or from the directory.❌input.json
outputstringPath to the file with the expected output for the test, can be a relative path from the configuration file or from the directory.❌
variablesstring or dictionaryVariables and corresponding values to pass to the GraphQL query❌variables.json
kindstringStatic value check-integration✅

Test kind graphql-query-smoke​

SpecTypeDescriptionMandatoryDefault
kindstringStatic value graphql-query-smoke✅
pathstringPath to the file in which the GraphQL query is defined✅

Test kind graphql-query-integration​

SpecTypeDescriptionMandatoryDefault
directorystringPath to the directory where the input and output files are located❌
inputstringPath to the file with the input data for the test, can be a relative path from the configuration file or from the directory.❌input.json
outputstringPath to the file with the expected output for the test, can be a relative path from the configuration file or from the directory.❌
variablesstring or dictionaryVariables and corresponding values to pass to the GraphQL query❌variables.json
kindstringStatic value graphql-query-integration✅
querystringName of a pre-defined GraphQL query to execute✅

Test kind jinja2-transform-smoke​

SpecTypeDescriptionMandatoryDefault
kindstringStatic value jinja2-transform-smoke✅

Test kind jinja2-transform-unit-render​

SpecTypeDescriptionMandatoryDefault
directorystringPath to the directory where the input and output files are located❌
inputstringPath to the file with the input data for the test, can be a relative path from the configuration file or from the directory.❌input.json
outputstringPath to the file with the expected output for the test, can be a relative path from the configuration file or from the directory.❌
kindstringStatic value jinja2-transform-unit-render✅

Test kind jinja2-transform-integration​

SpecTypeDescriptionMandatoryDefault
directorystringPath to the directory where the input and output files are located❌
inputstringPath to the file with the input data for the test, can be a relative path from the configuration file or from the directory.❌input.json
outputstringPath to the file with the expected output for the test, can be a relative path from the configuration file or from the directory.❌
variablesVariables and corresponding values to pass to the GraphQL query❌variables.json
kindstringStatic value jinja2-transform-integration✅

Test kind python-transform-smoke​

SpecTypeDescriptionMandatoryDefault
kindstringStatic value python-transform-smoke✅

Test kind python-transform-unit-process​

SpecTypeDescriptionMandatoryDefault
directorystringPath to the directory where the input and output files are located❌
inputstringPath to the file with the input data for the test, can be a relative path from the configuration file or from the directory.❌input.json
outputstringPath to the file with the expected output for the test, can be a relative path from the configuration file or from the directory.❌
kindstringStatic value python-transform-unit-process✅

Test kind python-transform-integration​

SpecTypeDescriptionMandatoryDefault
directorystringPath to the directory where the input and output files are located❌
inputstringPath to the file with the input data for the test, can be a relative path from the configuration file or from the directory.❌input.json
outputstringPath to the file with the expected output for the test, can be a relative path from the configuration file or from the directory.❌
variablesstring or dictionaryVariables and corresponding values to pass to the GraphQL query❌variables.json
kindstringStatic value python-transform-unit-process✅