Skip to content

Commit 3793ca7

Browse files
fix(parametermanager): add GoDoc comments to the test case functions
1 parent c6720d1 commit 3793ca7

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

parametermanager/regional_samples/regional_parametermanager_test.go

+30
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,24 @@ import (
3333
grpcstatus "google.golang.org/grpc/status"
3434
)
3535

36+
// testName generates a unique name for testing purposes by creating a new UUID.
37+
// It returns the UUID as a string or fails the test if UUID generation fails.
3638
func testName(t *testing.T) string {
39+
t.Helper()
40+
3741
u, err := uuid.NewV4()
3842
if err != nil {
3943
t.Fatalf("testName: failed to generate uuid: %v", err)
4044
}
4145
return u.String()
4246
}
4347

48+
// testLocation retrieves the location for testing purposes from the environment variable
49+
// GOLANG_REGIONAL_SAMPLES_LOCATION. If the environment variable is not set,
50+
// the test is skipped.
4451
func testLocation(t *testing.T) string {
52+
t.Helper()
53+
4554
v := os.Getenv("GOLANG_REGIONAL_SAMPLES_LOCATION")
4655
if v == "" {
4756
t.Skip("testLocation: missing GOLANG_REGIONAL_SAMPLES_LOCATION")
@@ -50,7 +59,10 @@ func testLocation(t *testing.T) string {
5059
return v
5160
}
5261

62+
// testParameterWithKmsKey creates a parameter with a KMS key in the specified GCP project.
63+
// It returns the created parameter and its ID or fails the test if parameter creation fails.
5364
func testParameterWithKmsKey(t *testing.T, projectID, kms_key string) (*parametermanagerpb.Parameter, string) {
65+
t.Helper()
5466
parameterID := testName(t)
5567
locationId := testLocation(t)
5668

@@ -78,7 +90,10 @@ func testParameterWithKmsKey(t *testing.T, projectID, kms_key string) (*paramete
7890
return parameter, parameterID
7991
}
8092

93+
// testCleanupParameter deletes the specified parameter in the GCP project.
94+
// It fails the test if the parameter deletion fails.
8195
func testCleanupParameter(t *testing.T, name string) {
96+
t.Helper()
8297
locationId := testLocation(t)
8398
ctx := context.Background()
8499

@@ -98,7 +113,10 @@ func testCleanupParameter(t *testing.T, name string) {
98113
}
99114
}
100115

116+
// testCleanupKeyVersions deletes the specified key version in the GCP project.
117+
// It fails the test if the key version deletion fails.
101118
func testCleanupKeyVersions(t *testing.T, name string) {
119+
t.Helper()
102120
ctx := context.Background()
103121

104122
client, err := kms.NewKeyManagementClient(ctx)
@@ -116,7 +134,10 @@ func testCleanupKeyVersions(t *testing.T, name string) {
116134
}
117135
}
118136

137+
// testCreateKeyRing creates a key ring in the specified GCP project.
138+
// It fails the test if the key ring creation fails.
119139
func testCreateKeyRing(t *testing.T, projectID, keyRingId string) {
140+
t.Helper()
120141
ctx := context.Background()
121142
locationID := testLocation(t)
122143

@@ -149,7 +170,10 @@ func testCreateKeyRing(t *testing.T, projectID, keyRingId string) {
149170
}
150171
}
151172

173+
// testCreateKeyHSM creates a HSM key in the specified key ring in the GCP project.
174+
// It fails the test if the key creation fails.
152175
func testCreateKeyHSM(t *testing.T, projectID, keyRing, id string) {
176+
t.Helper()
153177
ctx := context.Background()
154178
locationID := testLocation(t)
155179
client, err := kms.NewKeyManagementClient(ctx)
@@ -188,6 +212,8 @@ func testCreateKeyHSM(t *testing.T, projectID, keyRing, id string) {
188212
}
189213
}
190214

215+
// TestCreateRegionalParamWithKmsKey tests the createRegionalParamWithKmsKey function by creating a regional parameter with a KMS key,
216+
// and verifies if the parameter was successfully created by checking the output.
191217
func TestCreateRegionalParamWithKmsKey(t *testing.T) {
192218
tc := testutil.SystemTest(t)
193219

@@ -211,6 +237,8 @@ func TestCreateRegionalParamWithKmsKey(t *testing.T) {
211237
}
212238
}
213239

240+
// TestUpdateRegionalParamKmsKey tests the updateRegionalParamKmsKey function by creating a regional parameter with a KMS key,
241+
// updating the KMS key, and verifying if the parameter was successfully updated by checking the output.
214242
func TestUpdateRegionalParamKmsKey(t *testing.T) {
215243
tc := testutil.SystemTest(t)
216244

@@ -234,6 +262,8 @@ func TestUpdateRegionalParamKmsKey(t *testing.T) {
234262
}
235263
}
236264

265+
// TestRemoveRegionalParamKmsKey tests the removeRegionalParamKmsKey function by creating a regional parameter with a KMS key,
266+
// removing the KMS key, and verifying if the KMS key was successfully removed by checking the output.
237267
func TestRemoveRegionalParamKmsKey(t *testing.T) {
238268
tc := testutil.SystemTest(t)
239269

0 commit comments

Comments
 (0)