@@ -69,9 +69,9 @@ func TestGetPrivateLink(t *testing.T) {
69
69
"connections": [
70
70
{
71
71
"associationId": "received",
72
- "connectionId": 144019 ,
72
+ "connectionId": "vpce-con-12345678" ,
73
73
"type": "connection type",
74
- "ownerId": 12312312 ,
74
+ "ownerId": "123456789012" ,
75
75
"associationDate": "2024-07-16T09:26:40.929904847Z"
76
76
}
77
77
],
@@ -112,9 +112,9 @@ func TestGetPrivateLink(t *testing.T) {
112
112
ShareName : redis .String ("share name" ),
113
113
Connections : []* pl.PrivateLinkConnection {{
114
114
AssociationId : redis .String ("received" ),
115
- ConnectionId : redis .Int ( 144019 ),
115
+ ConnectionId : redis .String ( "vpce-con-12345678" ),
116
116
Type : redis .String ("connection type" ),
117
- OwnerId : redis .Int ( 12312312 ),
117
+ OwnerId : redis .String ( "123456789012" ),
118
118
AssociationDate : redis .String ("2024-07-16T09:26:40.929904847Z" ),
119
119
}},
120
120
Databases : []* pl.PrivateLinkDatabase {{
@@ -272,9 +272,9 @@ func TestGetActiveActivePrivateLink(t *testing.T) {
272
272
"connections": [
273
273
{
274
274
"associationId": "received",
275
- "connectionId": 144019 ,
275
+ "connectionId": "vpce-con-12345678" ,
276
276
"type": "connection type",
277
- "ownerId": 12312312 ,
277
+ "ownerId": "123456789012" ,
278
278
"associationDate": "2024-07-16T09:26:40.929904847Z"
279
279
}
280
280
],
@@ -316,9 +316,9 @@ func TestGetActiveActivePrivateLink(t *testing.T) {
316
316
ShareName : redis .String ("share name" ),
317
317
Connections : []* pl.PrivateLinkConnection {{
318
318
AssociationId : redis .String ("received" ),
319
- ConnectionId : redis .Int ( 144019 ),
319
+ ConnectionId : redis .String ( "vpce-con-12345678" ),
320
320
Type : redis .String ("connection type" ),
321
- OwnerId : redis .Int ( 12312312 ),
321
+ OwnerId : redis .String ( "123456789012" ),
322
322
AssociationDate : redis .String ("2024-07-16T09:26:40.929904847Z" ),
323
323
}},
324
324
Databases : []* pl.PrivateLinkDatabase {{
@@ -419,3 +419,89 @@ func TestGetActiveActivePrivateLink(t *testing.T) {
419
419
})
420
420
}
421
421
}
422
+
423
+ func TestGetPrivateLinkScript (t * testing.T ) {
424
+ t .Skipf ("skipping test until privatelink script is available" )
425
+
426
+ tc := []struct {
427
+ description string
428
+ mockedResponse []endpointRequest
429
+ expectedResult * pl.PrivateLinkEndpointScript
430
+ expectedError error
431
+ expectedErrorAs error
432
+ }{
433
+ {
434
+ description : "should successfully return a privatelink script" ,
435
+ mockedResponse : []endpointRequest {
436
+ getRequest (
437
+ t ,
438
+ "/subscriptions/114019/private-link/endpoint-script?includeTerraformAwsScript=true" ,
439
+ `a pro privatelink aws terraform endpoint script` ,
440
+ ),
441
+ },
442
+ expectedResult : redis .String ("a pro privatelink aws terraform endpoint script" ),
443
+ },
444
+ }
445
+ for _ , testCase := range tc {
446
+
447
+ t .Run (testCase .description , func (t * testing.T ) {
448
+ server := httptest .NewServer (
449
+ testServer ("key" , "secret" , testCase .mockedResponse ... ))
450
+
451
+ subject , err := clientFromTestServer (server , "key" , "secret" )
452
+ require .NoError (t , err )
453
+
454
+ actual , err := subject .PrivateLink .GetPrivateLinkEndpointScript (context .TODO (), 114019 )
455
+ if testCase .expectedError == nil {
456
+ assert .NoError (t , err )
457
+ assert .Equal (t , testCase .expectedResult , actual )
458
+ } else {
459
+ assert .IsType (t , err , testCase .expectedErrorAs )
460
+ assert .EqualError (t , err , testCase .expectedError .Error ())
461
+ }
462
+ })
463
+ }
464
+ }
465
+
466
+ func TestGetActiveActivePrivateLinkScript (t * testing.T ) {
467
+ t .Skipf ("skipping test until privatelink script is available" )
468
+
469
+ tc := []struct {
470
+ description string
471
+ mockedResponse []endpointRequest
472
+ expectedResult * pl.PrivateLinkEndpointScript
473
+ expectedError error
474
+ expectedErrorAs error
475
+ }{
476
+ {
477
+ description : "should successfully return an active active privatelink script" ,
478
+ mockedResponse : []endpointRequest {
479
+ getRequest (
480
+ t ,
481
+ "/subscriptions/114019/regions/1/private-link/endpoint-script?includeTerraformAwsScript=true" ,
482
+ `an active active aws terraform endpoint script` ,
483
+ ),
484
+ },
485
+ expectedResult : redis .String ("an active active aws terraform endpoint script" ),
486
+ },
487
+ }
488
+ for _ , testCase := range tc {
489
+
490
+ t .Run (testCase .description , func (t * testing.T ) {
491
+ server := httptest .NewServer (
492
+ testServer ("key" , "secret" , testCase .mockedResponse ... ))
493
+
494
+ subject , err := clientFromTestServer (server , "key" , "secret" )
495
+ require .NoError (t , err )
496
+
497
+ actual , err := subject .PrivateLink .GetActiveActivePrivateLinkEndpointScript (context .TODO (), 114019 , 1 )
498
+ if testCase .expectedError == nil {
499
+ assert .NoError (t , err )
500
+ assert .Equal (t , testCase .expectedResult , actual )
501
+ } else {
502
+ assert .IsType (t , err , testCase .expectedErrorAs )
503
+ assert .EqualError (t , err , testCase .expectedError .Error ())
504
+ }
505
+ })
506
+ }
507
+ }
0 commit comments