Skip to content

Commit 6e401b8

Browse files
committed
Address comment
1 parent 10afbcf commit 6e401b8

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

sumologic/resource_sumologic_token.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"log"
55

66
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
7+
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
78
)
89

910
func resourceSumologicToken() *schema.Resource {
@@ -39,8 +40,9 @@ func resourceSumologicToken() *schema.Resource {
3940
},
4041

4142
"type": {
42-
Type: schema.TypeString,
43-
Required: true,
43+
Type: schema.TypeString,
44+
Required: true,
45+
ValidateFunc: validation.StringInSlice([]string{"CollectorRegistration", "CollectorRegistrationTokenResponse"}, false),
4446
},
4547
},
4648
}

sumologic/resource_sumologic_token_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,23 @@ import (
66
"strings"
77
"testing"
88

9+
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
910
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
1011
"github.com/hashicorp/terraform-plugin-sdk/terraform"
1112
)
1213

14+
func getRandomizedParamsForToken() (string, string, string, string) {
15+
name := acctest.RandomWithPrefix("tf-acc-test")
16+
description := acctest.RandomWithPrefix("tf-acc-test")
17+
status := "Active"
18+
tokenType := "CollectorRegistrationToken"
19+
return name, description, status, tokenType
20+
}
21+
1322
func TestAccSumologicToken_basic(t *testing.T) {
1423
var token Token
1524

16-
testName := "Test Terraform Token"
17-
testDescription := "Description tf test token"
18-
testStatus := "Active"
25+
testName, testDescription, testStatus, _ := getRandomizedParamsForToken()
1926

2027
resource.Test(t, resource.TestCase{
2128
PreCheck: func() { testAccPreCheck(t) },
@@ -36,10 +43,7 @@ func TestAccSumologicToken_basic(t *testing.T) {
3643

3744
func TestAccSumologicToken_create(t *testing.T) {
3845
var token Token
39-
testName := "Test Terraform Token"
40-
testDescription := "Description tf test token"
41-
testStatus := "Active"
42-
testType := "CollectorRegistration"
46+
testName, testDescription, testStatus, testType := getRandomizedParamsForToken()
4347

4448
resource.Test(t, resource.TestCase{
4549
PreCheck: func() { testAccPreCheck(t) },
@@ -105,13 +109,9 @@ func testAccCheckTokenExists(name string, token *Token, t *testing.T) resource.T
105109

106110
func TestAccSumologicToken_update(t *testing.T) {
107111
var token Token
108-
testName := "Test Terraform Token"
109-
testDescription := "Description tf test token"
110-
testStatus := "Active"
111-
testType := "CollectorRegistration"
112+
testName, testDescription, testStatus, testType := getRandomizedParamsForToken()
112113

113-
testUpdatedName := "Test Terraform Token Update"
114-
testUpdatedDescription := "Description tf test token with update"
114+
testUpdatedName, testUpdatedDescription, _, _ := getRandomizedParamsForToken()
115115
testUpdatedStatus := "Inactive"
116116

117117
resource.Test(t, resource.TestCase{

0 commit comments

Comments
 (0)