Skip to content

Commit

Permalink
fix: set 'position_before' as computed
Browse files Browse the repository at this point in the history
  • Loading branch information
lriberon committed Jan 8, 2025
1 parent 53c8551 commit 4ea2f6c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
27 changes: 14 additions & 13 deletions datadome/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ func TestProviderConfigure(t *testing.T) {
Resources test helpers
*/

func testAccResourcePreCheck(t *testing.T) {}

// testAccCheckResourceExists check if the given resourceName exists
func testAccCheckResourceExists(resourceName string) resource.TestCheckFunc {
return func(s *terraform.State) error {
Expand Down Expand Up @@ -297,8 +299,6 @@ const testAccCustomRuleResourceConfigEmpty = `
provider "datadome" {}
`

func testAccCustomRuleResourcePreCheck(t *testing.T) {}

// TestAccCustomRuleResource_basic test the creation and the read of a new custom rule
func TestAccCustomRuleResource_basic(t *testing.T) {
mockClient := datadome.NewMockClientCustomRule()
Expand All @@ -310,7 +310,7 @@ func TestAccCustomRuleResource_basic(t *testing.T) {
}

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccCustomRuleResourcePreCheck(t) },
PreCheck: func() { testAccResourcePreCheck(t) },
ProviderFactories: testAccProviders,
Steps: []resource.TestStep{
{
Expand Down Expand Up @@ -340,7 +340,7 @@ func TestAccCustomRuleResource_update(t *testing.T) {
}

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccCustomRuleResourcePreCheck(t) },
PreCheck: func() { testAccResourcePreCheck(t) },
ProviderFactories: testAccProviders,
Steps: []resource.TestStep{
{
Expand Down Expand Up @@ -378,7 +378,7 @@ func TestAccCustomRuleResource_delete(t *testing.T) {
}

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccCustomRuleResourcePreCheck(t) },
PreCheck: func() { testAccResourcePreCheck(t) },
ProviderFactories: testAccProviders,
Steps: []resource.TestStep{
{
Expand Down Expand Up @@ -414,7 +414,7 @@ func TestAccCustomRuleResource_wrongParameters(t *testing.T) {
}

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccCustomRuleResourcePreCheck(t) },
PreCheck: func() { testAccResourcePreCheck(t) },
ProviderFactories: testAccProviders,
Steps: []resource.TestStep{
{
Expand Down Expand Up @@ -459,7 +459,7 @@ func TestAccCustomRuleResource_createAlreadyExists(t *testing.T) {
}

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccCustomRuleResourcePreCheck(t) },
PreCheck: func() { testAccResourcePreCheck(t) },
ProviderFactories: testAccProviders,
Steps: []resource.TestStep{
{
Expand All @@ -484,7 +484,7 @@ func TestAccCustomRuleResource_updateAlreadyExists(t *testing.T) {
}

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccCustomRuleResourcePreCheck(t) },
PreCheck: func() { testAccResourcePreCheck(t) },
ProviderFactories: testAccProviders,
Steps: []resource.TestStep{
{
Expand Down Expand Up @@ -723,7 +723,7 @@ func TestAccEndpointResource_basic(t *testing.T) {
}

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccCustomRuleResourcePreCheck(t) },
PreCheck: func() { testAccResourcePreCheck(t) },
ProviderFactories: testAccProviders,
Steps: []resource.TestStep{
{
Expand All @@ -739,6 +739,7 @@ func TestAccEndpointResource_basic(t *testing.T) {
resource.TestCheckResourceAttr("datadome_endpoint.simple", "source", "Web Browser"),
resource.TestCheckResourceAttr("datadome_endpoint.simple", "traffic_usage", "Account Creation"),
resource.TestCheckResourceAttr("datadome_endpoint.simple", "user_agent_inclusion", "TFTEST"),
resource.TestCheckResourceAttrSet("datadome_endpoint.simple", "position_before"),
),
},
},
Expand All @@ -756,7 +757,7 @@ func TestAccEndpointResource_createWithoutOptionalFields(t *testing.T) {
}

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccCustomRuleResourcePreCheck(t) },
PreCheck: func() { testAccResourcePreCheck(t) },
ProviderFactories: testAccProviders,
Steps: []resource.TestStep{
{
Expand Down Expand Up @@ -790,7 +791,7 @@ func TestAccEndpointResource_createWithPositionBefore(t *testing.T) {
}

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccCustomRuleResourcePreCheck(t) },
PreCheck: func() { testAccResourcePreCheck(t) },
ProviderFactories: testAccProviders,
Steps: []resource.TestStep{
{
Expand Down Expand Up @@ -822,7 +823,7 @@ func TestAccEndpointResource_createWithRegex(t *testing.T) {
}

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccCustomRuleResourcePreCheck(t) },
PreCheck: func() { testAccResourcePreCheck(t) },
ProviderFactories: testAccProviders,
Steps: []resource.TestStep{
{
Expand Down Expand Up @@ -855,7 +856,7 @@ func TestAccEndpointResource_wrongParameters(t *testing.T) {
}

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccCustomRuleResourcePreCheck(t) },
PreCheck: func() { testAccResourcePreCheck(t) },
ProviderFactories: testAccProviders,
Steps: []resource.TestStep{
{
Expand Down
5 changes: 2 additions & 3 deletions datadome/resource_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func resourceEndpoint() *schema.Resource {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.IsUUID,
Computed: true,
},
"traffic_usage": {
Type: schema.TypeString,
Expand Down Expand Up @@ -187,8 +188,6 @@ func resourceEndpointCreate(ctx context.Context, d *schema.ResourceData, m inter
config := m.(*ProviderConfig)
c := config.ClientEndpoint

var diags diag.Diagnostics

var description *string
descriptionValue, ok := d.GetOk("description")
if ok {
Expand Down Expand Up @@ -249,7 +248,7 @@ func resourceEndpointCreate(ctx context.Context, d *schema.ResourceData, m inter

d.SetId(*id)

return diags
return resourceEndpointRead(ctx, d, m)
}

// resourceEndpointRead is used to fetch the custom rule by its ID
Expand Down

0 comments on commit 4ea2f6c

Please sign in to comment.