Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated tagging acceptance tests for Batch resources #36517

Merged
merged 4 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/36517.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_batch_scheduling_policy: Fixes error where tags could not be updated
```
9 changes: 9 additions & 0 deletions internal/generate/tagstests/file.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ func TestAcc{{ .ProviderNameUpper }}{{ .Name }}_tags(t *testing.T) {
}

func TestAcc{{ .ProviderNameUpper }}{{ .Name }}_tags_null(t *testing.T) {
{{- if eq .Implementation "framework" }}
t.Skip("Tags with null values are not correctly handled with the Plugin Framework")
{{ end }}
{{- template "Init" . }}

resource.ParallelTest(t, resource.TestCase{
Expand Down Expand Up @@ -496,6 +499,9 @@ func TestAcc{{ .ProviderNameUpper }}{{ .Name }}_tags_DefaultTags_emptyResourceTa
}

func TestAcc{{ .ProviderNameUpper }}{{ .Name }}_tags_DefaultTags_nullOverlappingResourceTag(t *testing.T) {
{{- if eq .Implementation "framework" }}
t.Skip("Tags with null values are not correctly handled with the Plugin Framework")
{{ end }}
{{- template "Init" . }}

resource.ParallelTest(t, resource.TestCase{
Expand All @@ -519,6 +525,9 @@ func TestAcc{{ .ProviderNameUpper }}{{ .Name }}_tags_DefaultTags_nullOverlapping
}

func TestAcc{{ .ProviderNameUpper }}{{ .Name }}_tags_DefaultTags_nullNonOverlappingResourceTag(t *testing.T) {
{{- if eq .Implementation "framework" }}
t.Skip("Tags with null values are not correctly handled with the Plugin Framework")
{{ end }}
{{- template "Init" . }}

resource.ParallelTest(t, resource.TestCase{
Expand Down
10 changes: 10 additions & 0 deletions internal/generate/tagstests/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ func main() {
}
}

type implementation string

const (
implementationFramework implementation = "framework"
implementationSDK implementation = "sdk"
)

type ResourceDatum struct {
ProviderPackage string
ProviderNameUpper string
Expand All @@ -101,6 +108,7 @@ type ResourceDatum struct {
FileName string
Generator string
ImportIgnore []string
Implementation implementation
}

//go:embed file.tmpl
Expand Down Expand Up @@ -174,6 +182,7 @@ func (v *visitor) processFuncDecl(funcDecl *ast.FuncDecl) {
if m := annotation.FindStringSubmatch(line); len(m) > 0 {
switch annotationName := m[1]; annotationName {
case "FrameworkResource":
d.Implementation = implementationFramework
args := common.ParseArgs(m[3])
if len(args.Positional) == 0 {
v.errs = append(v.errs, fmt.Errorf("no type name: %s", fmt.Sprintf("%s.%s", v.packageName, v.functionName)))
Expand All @@ -185,6 +194,7 @@ func (v *visitor) processFuncDecl(funcDecl *ast.FuncDecl) {
}

case "SDKResource":
d.Implementation = implementationSDK
args := common.ParseArgs(m[3])
if len(args.Positional) == 0 {
v.errs = append(v.errs, fmt.Errorf("no type name: %s", fmt.Sprintf("%s.%s", v.packageName, v.functionName)))
Expand Down
1 change: 1 addition & 0 deletions internal/service/batch/compute_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (

// @SDKResource("aws_batch_compute_environment", name="Compute Environment")
// @Tags(identifierAttribute="arn")
// @Testing(existsType="github.com/aws/aws-sdk-go/service/batch.ComputeEnvironmentDetail")
func ResourceComputeEnvironment() *schema.Resource {
return &schema.Resource{
CreateWithoutTimeout: resourceComputeEnvironmentCreate,
Expand Down
Loading
Loading