AT010

package
v0.29.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 13, 2023 License: MPL-2.0 Imports: 4 Imported by: 2

README

AT010

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.

Flagged Code

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"),
                ),
            },
        },
    })
}

Passing Code

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 the a //lintignore:AT010 Go code comment on the line immediately proceding, 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"),
                ),
            },
        },
    })
}

Documentation

Index

Constants

View Source
const Doc = `` /* 308-byte string literal not displayed */

Variables

View Source
var Analyzer = &analysis.Analyzer{
	Name: analyzerName,
	Doc:  Doc,
	Requires: []*analysis.Analyzer{
		commentignore.Analyzer,
		testcaseinfo.Analyzer,
	},
	Run: run,
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL