Skip to content

Commit

Permalink
Merge pull request #37688 from hashicorp/t-acctest-literal-overlapkey…
Browse files Browse the repository at this point in the history
…1-resourcekey1-string-constant

ci: Prefer constants for test string literals
  • Loading branch information
YakDriver committed May 24, 2024
2 parents c6f10da + 9a43aad commit f9378aa
Show file tree
Hide file tree
Showing 40 changed files with 3,533 additions and 3,473 deletions.
45 changes: 45 additions & 0 deletions .ci/.semgrep-test-constants.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,33 @@ rules:
pattern: '"key2"'
severity: ERROR
fix: "acctest.CtKey2"
- id: literal-Name-string-test-constant
languages: [go]
message: Use the constant `acctest.CtName` for the string literal "name" in test files
paths:
include:
- "internal/service/**/*_test.go"
pattern: '"name"'
severity: ERROR
fix: "acctest.CtName"
- id: literal-OverlapKey1-string-test-constant
languages: [go]
message: Use the constant `acctest.CtOverlapKey1` for the string literal "overlapkey1" in test files
paths:
include:
- "internal/service/**/*_test.go"
pattern: '"overlapkey1"'
severity: ERROR
fix: "acctest.CtOverlapKey1"
- id: literal-ProviderKey1-string-test-constant
languages: [go]
message: Use the constant `acctest.CtProviderKey1` for the string literal "providerkey1" in test files
paths:
include:
- "internal/service/**/*_test.go"
pattern: '"providerkey1"'
severity: ERROR
fix: "acctest.CtProviderKey1"
- id: literal-ProviderTags-string-test-constant
languages: [go]
message: Use the constant `acctest.CtProviderTags` for the string literal "provider_tags" in test files
Expand Down Expand Up @@ -138,6 +165,24 @@ rules:
pattern: '"rName"'
severity: ERROR
fix: "acctest.CtRName"
- id: literal-ResourceKey1-string-test-constant
languages: [go]
message: Use the constant `acctest.CtResourceKey1` for the string literal "resourcekey1" in test files
paths:
include:
- "internal/service/**/*_test.go"
pattern: '"resourcekey1"'
severity: ERROR
fix: "acctest.CtResourceKey1"
- id: literal-ResourceTags-string-test-constant
languages: [go]
message: Use the constant `acctest.CtResourceTags` for the string literal "resource_tags" in test files
paths:
include:
- "internal/service/**/*_test.go"
pattern: '"resource_tags"'
severity: ERROR
fix: "acctest.CtResourceTags"
- id: literal-ResourceValue1-string-test-constant
languages: [go]
message: Use the constant `acctest.CtResourceValue1` for the string literal "resourcevalue1" in test files
Expand Down
5 changes: 5 additions & 0 deletions internal/acctest/consts.csv
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@ basic,Basic
false,False
key1,Key1
key2,Key2
name,Name
overlapkey1,OverlapKey1
provider_tags,ProviderTags
providerkey1,ProviderKey1
providervalue1,ProviderValue1
rName,RName
resource_tags,ResourceTags
resourcekey1,ResourceKey1
resourcevalue1,ResourceValue1
resourcevalue2,ResourceValue2
rule.#,RulePound
Expand Down
10 changes: 10 additions & 0 deletions internal/acctest/consts_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

224 changes: 112 additions & 112 deletions internal/generate/tagstests/test.go.gtpl

Large diffs are not rendered by default.

0 comments on commit f9378aa

Please sign in to comment.