Skip to content

Support for combining multiple fixtures? #30

@dnouri

Description

@dnouri

I was looking for a way to split up my terraform fixtures, to have a base fixture that could be used by more than one test, and then have per-test fixtures on top of those, while the per-test fixtures will maybe typically reference resources from the base fixture.

My naive attempt at doing this was by combining two @terraform decorators, looking like this:

@terraform('my_base_fixture', scope='session')
@terraform('my_test_fixture')
def my_test(my_base_fixture, my_test_fixture):
    pass 

The result of that is that the first fixture is executed fine, but generating a terraform plan for the second fixture fails, due to terraform not being able to look up referenced resources. Error: Reference to undeclared resource

I had some luck using Terraform data sources to be able to refer to resources in the base fixture from within the specialized test fixture. The remaining issue there was that I couldn't seemingly control the order of teardowns, such that the base fixture was always torn down first, resulting in failure during the tear down of the specialized fixture to look up the resources defined via data sources.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions