Skip to content

Commit 2b54e79

Browse files
Fix test
1 parent 36a5739 commit 2b54e79

File tree

1 file changed

+16
-31
lines changed

1 file changed

+16
-31
lines changed

cloud/service_account_binding_test.go

Lines changed: 16 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package cloud
1717
import (
1818
"context"
1919
"fmt"
20+
"math/rand"
2021
"strings"
2122
"testing"
2223
"time"
@@ -27,6 +28,8 @@ import (
2728
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2829
)
2930

31+
var saGeneratedName = fmt.Sprintf("t-%d-%d", rand.Intn(1000), rand.Intn(100))
32+
3033
func TestServiceAccountBinding(t *testing.T) {
3134
resource.Test(t, resource.TestCase{
3235
PreCheck: func() {
@@ -38,10 +41,9 @@ func TestServiceAccountBinding(t *testing.T) {
3841
{
3942
Config: testResourceDataSourceServiceAccountBinding(
4043
"sndev",
41-
clusterGeneratedName,
42-
"shared-gcp-prod",
43-
"streamnative",
44-
"us-central1", "rapid"),
44+
saGeneratedName,
45+
"gcp-shared-usc1-test",
46+
"streamnative"),
4547
Check: resource.ComposeTestCheckFunc(
4648
testCheckServiceAccountBindingExists("streamnative_service_account_binding.test-service-account-binding"),
4749
),
@@ -63,10 +65,9 @@ func TestServiceAccountBindingRemovedExternally(t *testing.T) {
6365
{
6466
Config: testResourceDataSourceServiceAccountBinding(
6567
"sndev",
66-
clusterGeneratedName,
67-
"shared-gcp-prod",
68-
"streamnative",
69-
"us-central1", "rapid"),
68+
saGeneratedName,
69+
"gcp-shared-usc1-test",
70+
"streamnative"),
7071
Check: resource.ComposeTestCheckFunc(
7172
testCheckServiceAccountBindingExists("streamnative_service_account_binding.test-service-account-binding"),
7273
),
@@ -87,10 +88,9 @@ func TestServiceAccountBindingRemovedExternally(t *testing.T) {
8788
},
8889
Config: testResourceDataSourceServiceAccountBinding(
8990
"sndev",
90-
clusterGeneratedName,
91-
"shared-gcp-prod",
92-
"streamnative",
93-
"us-central1", "rapid"),
91+
saGeneratedName,
92+
"gcp-shared-usc1-test",
93+
"streamnative"),
9494
PlanOnly: true,
9595
ExpectNonEmptyPlan: true,
9696
},
@@ -156,26 +156,10 @@ func testCheckServiceAccountBindingExists(name string) resource.TestCheckFunc {
156156
}
157157
}
158158

159-
func testResourceDataSourceServiceAccountBinding(organization, name, poolName, poolNamespace, location, releaseChannel string) string {
159+
func testResourceDataSourceServiceAccountBinding(organization, name, poolMemberName, poolMemberNamespace string) string {
160160
return fmt.Sprintf(`
161161
provider "streamnative" {
162162
}
163-
resource "streamnative_pulsar_instance" "test-pulsar-instance" {
164-
organization = "%s"
165-
name = "%s"
166-
availability_mode = "zonal"
167-
pool_name = "%s"
168-
pool_namespace = "%s"
169-
type = "dedicated"
170-
}
171-
resource "streamnative_pulsar_cluster" "test-pulsar-cluster" {
172-
organization = "%s"
173-
name = "%s"
174-
instance_name = "%s"
175-
location = "%s"
176-
release_channel = "%s"
177-
depends_on = [streamnative_pulsar_instance.test-pulsar-instance]
178-
}
179163
180164
resource "streamnative_service_account" "test-service-account" {
181165
organization = "%s"
@@ -186,7 +170,8 @@ resource "streamnative_service_account" "test-service-account" {
186170
resource "streamnative_service_account_binding" "test-service-account-binding" {
187171
organization = "%s"
188172
service_account_name = streamnative_service_account.test-service-account.name
189-
cluster_name = streamnative_pulsar_cluster.test-pulsar-cluster.name
173+
pool_member_name = "%s"
174+
pool_member_namespace = "%s"
190175
enable_iam_account_creation = true
191176
}
192177
@@ -196,5 +181,5 @@ data "streamnative_service_account_binding" "test-service-account-binding" {
196181
name = streamnative_service_account_binding.test-service-account-binding.name
197182
}
198183
199-
`, organization, name, poolName, poolNamespace, organization, name, name, location, releaseChannel, organization, name, true, organization)
184+
`, organization, name, true, organization, poolMemberName, poolMemberNamespace)
200185
}

0 commit comments

Comments
 (0)