Skip to content

Commit

Permalink
aws_codeguruprofiler_profiling_group: add datasource tests
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsonaj committed Dec 1, 2023
1 parent 0f10878 commit a7d6b53
Showing 1 changed file with 61 additions and 89 deletions.
150 changes: 61 additions & 89 deletions internal/service/codeguruprofiler/profiling_group_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,92 +3,64 @@

package codeguruprofiler_test

//import (
// "fmt"
// "strings"
// "testing"
//
// "github.com/YakDriver/regexache"
//
// "github.com/aws/aws-sdk-go-v2/aws"
// "github.com/aws/aws-sdk-go-v2/service/codeguruprofiler"
// "github.com/aws/aws-sdk-go-v2/service/codeguruprofiler/types"
// "github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2/tfawserr"
// "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
// sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest"
// "github.com/hashicorp/terraform-plugin-testing/helper/resource"
// "github.com/hashicorp/terraform-plugin-testing/terraform"
// "github.com/hashicorp/terraform-provider-aws/internal/acctest"
// "github.com/hashicorp/terraform-provider-aws/internal/conns"
// "github.com/hashicorp/terraform-provider-aws/internal/create"
// tfcodeguruprofiler "github.com/hashicorp/terraform-provider-aws/internal/service/codeguruprofiler"
// "github.com/hashicorp/terraform-provider-aws/names"
//)
//
//
//
//func TestAccCodeGuruProfilerProfilingGroupDataSource_basic(t *testing.T) {
// ctx := acctest.Context(t)
// if testing.Short() {
// t.Skip("skipping long-running test in short mode")
// }
//
// var profilinggroup codeguruprofiler.DescribeProfilingGroupResponse
// rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
// dataSourceName := "data.aws_codeguruprofiler_profiling_group.test"
//
// resource.ParallelTest(t, resource.TestCase{
// PreCheck: func() {
// acctest.PreCheck(ctx, t)
// acctest.PreCheckPartitionHasService(t, codeguruprofiler.EndpointsID)
// testAccPreCheck(ctx, t)
// },
// ErrorCheck: acctest.ErrorCheck(t, names.CodeGuruProfilerEndpointID),
// ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
// CheckDestroy: testAccCheckProfilingGroupDestroy(ctx),
// Steps: []resource.TestStep{
// {
// Config: testAccProfilingGroupDataSourceConfig_basic(rName),
// Check: resource.ComposeTestCheckFunc(
// testAccCheckProfilingGroupExists(ctx, dataSourceName, &profilinggroup),
// resource.TestCheckResourceAttr(dataSourceName, "auto_minor_version_upgrade", "false"),
// resource.TestCheckResourceAttrSet(dataSourceName, "maintenance_window_start_time.0.day_of_week"),
// resource.TestCheckTypeSetElemNestedAttrs(dataSourceName, "user.*", map[string]string{
// "console_access": "false",
// "groups.#": "0",
// "username": "Test",
// "password": "TestTest1234",
// }),
// acctest.MatchResourceAttrRegionalARN(dataSourceName, "arn", "codeguruprofiler", regexache.MustCompile(`profilinggroup:+.`)),
// ),
// },
// },
// })
//}
//
//func testAccProfilingGroupDataSourceConfig_basic(rName, version string) string {
// return fmt.Sprintf(`
//data "aws_security_group" "test" {
// name = %[1]q
//}
//
//data "aws_codeguruprofiler_profiling_group" "test" {
// profiling_group_name = %[1]q
// engine_type = "ActiveCodeGuruProfiler"
// engine_version = %[2]q
// host_instance_type = "codeguruprofiler.t2.micro"
// security_groups = [aws_security_group.test.id]
// authentication_strategy = "simple"
// storage_type = "efs"
//
// logs {
// general = true
// }
//
// user {
// username = "Test"
// password = "TestTest1234"
// }
//}
//`, rName, version)
//}
import (
"fmt"
"testing"

awstypes "github.com/aws/aws-sdk-go-v2/service/codeguruprofiler/types"
sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-provider-aws/internal/acctest"
"github.com/hashicorp/terraform-provider-aws/names"
)

func TestAccCodeGuruProfilerProfilingGroupDataSource_basic(t *testing.T) {
ctx := acctest.Context(t)
if testing.Short() {
t.Skip("skipping long-running test in short mode")
}

var profilinggroup awstypes.ProfilingGroupDescription
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
dataSourceName := "data.aws_codeguruprofiler_profiling_group.test"
resourceName := "aws_codeguruprofiler_profiling_group.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() {
acctest.PreCheck(ctx, t)
testAccPreCheck(ctx, t)
},
ErrorCheck: acctest.ErrorCheck(t, names.CodeGuruProfilerEndpointID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckProfilingGroupDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccProfilingGroupDataSourceConfig_basic(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckProfilingGroupExists(ctx, dataSourceName, &profilinggroup),
resource.TestCheckResourceAttrPair(dataSourceName, "name", resourceName, "name"),
resource.TestCheckResourceAttrPair(dataSourceName, "arn", resourceName, "arn"),
resource.TestCheckResourceAttrPair(dataSourceName, "compute_platform", resourceName, "compute_platform"),
resource.TestCheckResourceAttrPair(dataSourceName, "agent_orchestration_config.0.profiling_enabled", resourceName, "agent_orchestration_config.0.profiling_enabled"),
),
},
},
})
}

func testAccProfilingGroupDataSourceConfig_basic(rName string) string {
return fmt.Sprintf(`
resource "aws_codeguruprofiler_profiling_group" "test" {
name = %[1]q
compute_platform = "Default"
agent_orchestration_config {
profiling_enabled = true
}
}
data "aws_codeguruprofiler_profiling_group" "test" {
name = aws_codeguruprofiler_profiling_group.test.name
}
`, rName)
}

0 comments on commit a7d6b53

Please sign in to comment.