File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66 "slices"
77 "testing"
88
9+ "github.com/google/uuid"
910 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
1011 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
1112 "github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
@@ -27,7 +28,7 @@ func TestAccOrgAPIKeys(t *testing.T) {
2728 t .Fatal (err )
2829 }
2930
30- wantKeyName := projectNamePrefix + "orgApikey"
31+ wantKeyName := projectNamePrefix + "orgApikey" + uuid . NewString ()
3132
3233 t .Cleanup (func () {
3334 keys , _ := client .ListOrgApiKeys (orgID )
Original file line number Diff line number Diff line change @@ -3,8 +3,10 @@ package provider
33import (
44 "fmt"
55 "os"
6+ "strings"
67 "testing"
78
9+ "github.com/google/uuid"
810 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
911 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
1012 "github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
@@ -41,8 +43,24 @@ func TestRecreateAPIKeyIfNotFound(t *testing.T) {
4143
4244 }
4345
46+ t .Cleanup (func () {
47+ ref , err := client .ListApiKeys ()
48+ if err != nil {
49+ panic (err )
50+ }
51+
52+ for _ , key := range ref {
53+ if strings .HasPrefix (key .Name , "test" ) {
54+ _ , err = client .RevokeApiKey (key .ID )
55+ if err != nil {
56+ panic (err )
57+ }
58+ }
59+ }
60+ })
61+
4462 t .Run ("shall indicate non empty plan if the API key was deleted outside of terraform" , func (t * testing.T ) {
45- keyName := "test"
63+ keyName := "test" + uuid . NewString ()
4664 resource .Test (
4765 t , resource.TestCase {
4866 ProviderFactories : map [string ]func () (* schema.Provider , error ){
@@ -72,7 +90,7 @@ func TestRecreateAPIKeyIfNotFound(t *testing.T) {
7290 })
7391
7492 t .Run ("shall destroy even if the API key was deleted outside of terraform," , func (t * testing.T ) {
75- keyName := "test"
93+ keyName := "test" + uuid . NewString ()
7694 config := fmt .Sprintf (`resource "neon_api_key" "this" {name = "%s"}` , keyName )
7795 resource .Test (
7896 t , resource.TestCase {
You can’t perform that action at this time.
0 commit comments