Skip to content

Commit

Permalink
update test files
Browse files Browse the repository at this point in the history
Signed-off-by: Rumen Vasilev <[email protected]>
  • Loading branch information
rumenvasilev committed Oct 18, 2024
1 parent d3c6f24 commit cc0a13f
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 54 deletions.
53 changes: 0 additions & 53 deletions internal/provider/example_resource_test.go

This file was deleted.

57 changes: 57 additions & 0 deletions internal/provider/parameter_resource_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package provider

import (
"fmt"
"testing"

"github.com/hashicorp/terraform-plugin-testing/helper/resource"
)

func TestAccParameterResource(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
Steps: []resource.TestStep{
// Create and Read testing
{
Config: testAccParameterResourceConfig("one"),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("fastssm_parameter.test", "name", "one"),
resource.TestCheckResourceAttr("fastssm_parameter.test", "value", "one"),
resource.TestCheckResourceAttr("fastssm_parameter.test", "overwrite", "false"),
// resource.TestCheckResourceAttr("fastssm_parameter.test", "defaulted", "Parameter value when not configured"),
// resource.TestCheckResourceAttr("fastssm_parameter.test", "id", "Parameter-id"),
),
},
// ImportState testing
{
ResourceName: "fastssm_parameter.test",
ImportState: true,
ImportStateVerify: true,
// This is not normally necessary, but is here because this
// Parameter code does not have an actual upstream service.
// Once the Read method is able to refresh information from
// the upstream service, this can be removed.
ImportStateVerifyIgnore: []string{"name", "one"},
},
// Update and Read testing
{
Config: testAccParameterResourceConfig("two"),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("fastssm_parameter.test", "name", "two"),
),
},
// Delete testing automatically occurs in TestCase
},
})
}

func testAccParameterResourceConfig(configurableAttribute string) string {
return fmt.Sprintf(`
resource "fastssm_parameter" "test" {
name = %[1]q
insecure_value = %[1]q
type = "String"
}
`, configurableAttribute)
}
2 changes: 1 addition & 1 deletion internal/provider/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
// CLI command executed to create a provider server to which the CLI can
// reattach.
var testAccProtoV6ProviderFactories = map[string]func() (tfprotov6.ProviderServer, error){
"scaffolding": providerserver.NewProtocol6WithError(New("test")()),
"fastssm": providerserver.NewProtocol6WithError(New("test")()),
}

func testAccPreCheck(t *testing.T) {
Expand Down

0 comments on commit cc0a13f

Please sign in to comment.