hashicorp / pandora

A suite of single-purpose tools enabling automation for Terraform/Azure
Mozilla Public License 2.0
65 stars 46 forks source link

V2 API Definitions - outputting the tests as a part of the Resource Definition #3352

Open tombuildsstuff opened 10 months ago

tombuildsstuff commented 10 months ago

Currently the Terraform Resource Definition doesn't contain any reference to the Tests we're expecting, which are instead loaded from the Tests directory and assumed to be correct.

As such we should add a section to the Terraform Resource Definition outputting which tests are available e.g.:

{
    "apiVersion": "2023-03-02-preview",
    "...": "...",
    "tests": {
        "generate": true,
        "basic": "Tests/ExampleResource-Basic.hcl",
        "requiresImport": "Tests/ExampleResource-RequiresImport.hcl",
        "complete": "Tests/ExampleResource-Complete.hcl",
        "other": {
            "SomeCustomTest": [
                "Tests/ExampleResource-SomeCustomTest-01.hcl",
                "Tests/ExampleResource-SomeCustomTest-02.hcl",
            ]
        },
        "...": "...",
    },

This means that we can both ensure all of the tests we're expecting are present (which'll help when implementing hot reloading for Data API v2 / the serve-watch command) - and means that we can potentially source these from other paths in the future (for example, sourcing the test configurations from files we're using for examples), far more easily - rather than relying on the files being in a given format.

mbfrahry commented 9 months ago

This has been mostly fixed with #3341 but Tests.Generate is not being output anymore from rest-importer-api-specs to the data-api per this comment.