Skip to content

Commit

Permalink
added remove default on create rules, add slug to schema on create
Browse files Browse the repository at this point in the history
  • Loading branch information
zander-canva committed Aug 26, 2022
1 parent 7a5c996 commit 338c636
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sentry/resource_sentry_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ func resourceSentryProjectCreate(ctx context.Context, d *schema.ResourceData, me
teams = d.Get("teams").(*schema.Set).List()
team = teams[0].(string)
}

params := &sentry.CreateProjectParams{
Name: d.Get("name").(string),
Slug: d.Get("slug").(string),
Expand All @@ -182,6 +183,7 @@ func resourceSentryProjectCreate(ctx context.Context, d *schema.ResourceData, me
})

d.SetId(proj.Slug)
d.Set("slug", proj.Slug)
return resourceSentryProjectUpdate(ctx, d, meta)
}

Expand Down
36 changes: 36 additions & 0 deletions sentry/resource_sentry_project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,42 @@ func TestAccSentryProject_basic(t *testing.T) {
})
}

func TestAccSentryProject_removeDefaultKeyOnCreate(t *testing.T) {
teamName := acctest.RandomWithPrefix("tf-team")
projectName := acctest.RandomWithPrefix("tf-project")
rn := "sentry_project.test"

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckSentryProjectDestroy,
Steps: []resource.TestStep{
{
Config: testAccSentryProjectConfigComplex(teamName, projectName, true, false),
Check: testAccSentryKeyRemoved(rn),
},
},
})
}

func TestAccSentryProject_removeDefaultRuleOnCreate(t *testing.T) {
teamName := acctest.RandomWithPrefix("tf-team")
projectName := acctest.RandomWithPrefix("tf-project")
rn := "sentry_project.test"

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckSentryProjectDestroy,
Steps: []resource.TestStep{
{
Config: testAccSentryProjectConfigComplex(teamName, projectName, false, true),
Check: testAccSentryRuleRemoved(rn),
},
},
})
}

func TestAccSentryProject_changeTeam(t *testing.T) {
teamName1 := acctest.RandomWithPrefix("tf-team")
teamName2 := acctest.RandomWithPrefix("tf-team")
Expand Down

0 comments on commit 338c636

Please sign in to comment.