AT010

Acceptance testsStandard

check for TestCase including IDRefreshName implementation

The AT010 analyzer reports likely extraneous use of ID-only refresh testing. Most resources should prefer to include a TestStep with ImportState instead since it will cover the same testing functionality along with verifying resource import support.

Examples

func TestAccExampleThing_Attr1(t *testing.T) {
    resource.ParallelTest(t, resource.TestCase{
        PreCheck:      func() { testAccPreCheck(t) },
        Providers:     testAccProviders,
        IDRefreshName: "example_thing.test",
        Steps: []resource.TestStep{
            {
                Config: testAccExampleThingConfig(),
                Check: resource.ComposeTestCheckFunc(
                    resource.TestCheckResourceAttrSet("example_thing.test", "attr1"),
                ),
            },
        },
    })
}
func TestAccExampleThing_Attr1(t *testing.T) {
    resource.ParallelTest(t, resource.TestCase{
        PreCheck:      func() { testAccPreCheck(t) },
        Providers:     testAccProviders,
        Steps: []resource.TestStep{
            {
                Config: testAccExampleThingConfig(),
                Check: resource.ComposeTestCheckFunc(
                    resource.TestCheckResourceAttrSet("example_thing.test", "attr1"),
                ),
            },
            {
                Config:            testAccExampleThingConfig(),
                ImportState:       true,
                ImportStateVerify: true,
            },
        },
    })
}

Ignoring reports

Singular reports can be ignored by adding a //lintignore:AT010 Go code comment on the line immediately preceding, e.g.

func TestAccExampleThing_Attr1(t *testing.T) {
    resource.ParallelTest(t, resource.TestCase{
        PreCheck:      func() { testAccPreCheck(t) },
        Providers:     testAccProviders,
        //lintignore:AT010
        IDRefreshName: "example_thing.test",
        Steps: []resource.TestStep{
            {
                Config: testAccExampleThingConfig(),
                Check: resource.ComposeTestCheckFunc(
                    resource.TestCheckResourceAttrSet("example_thing.test", "attr1"),
                ),
            },
        },
    })
}

This page is generated from passes/AT010/README.md, which lives beside the analyzer.