From 92049ecc3b2857f7b6ecb970eb66f1d4f44e716e Mon Sep 17 00:00:00 2001 From: Aleksandr Boldyrev Date: Mon, 4 Nov 2024 11:48:43 +0100 Subject: [PATCH 01/12] Fix Private Links custom config --- private_link/private_link_create.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/private_link/private_link_create.go b/private_link/private_link_create.go index fa40c4e..f3ad57a 100644 --- a/private_link/private_link_create.go +++ b/private_link/private_link_create.go @@ -91,7 +91,7 @@ func (s *PrivateLinkCreateService) ConfigCustom(value *map[string]interface{}) * } func (s *PrivateLinkCreateService) do(ctx context.Context, req, response any) error { - err := s.HttpService.Do(ctx, "POST", "/private-links", s.request(), nil, 201, &response) + err := s.HttpService.Do(ctx, "POST", "/private-links", req, nil, 201, &response) return err } From b48995bcf9f7c5fb7c2e977e4f5bdf4cc07e12ba Mon Sep 17 00:00:00 2001 From: Aleksandr Boldyrev Date: Mon, 4 Nov 2024 11:51:31 +0100 Subject: [PATCH 02/12] Update private_link_create_test.go --- tests/e2e/private_link_create_test.go | 32 ++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/tests/e2e/private_link_create_test.go b/tests/e2e/private_link_create_test.go index 2b5cb1c..d2472c9 100644 --- a/tests/e2e/private_link_create_test.go +++ b/tests/e2e/private_link_create_test.go @@ -9,7 +9,7 @@ import ( ) func TestNewPrivateLinkCreateE2E(t *testing.T) { - t.Skip("Private links have a strict limit on the number of requests per hour; to test changes in these modules, this Skip must be removed") + //t.Skip("Private links have a strict limit on the number of requests per hour; to test changes in these modules, this Skip must be removed") created, err := testutils.Client.NewPrivateLinkCreate(). Name("go_sdk_private_link_test"). @@ -36,3 +36,33 @@ func TestNewPrivateLinkCreateE2E(t *testing.T) { testutils.DeletePrivateLink(t, created.Data.Id) }) } + +func TestNewPrivateLinkCustomCreateE2E(t *testing.T) { + //t.Skip("Private links have a strict limit on the number of requests per hour; to test changes in these modules, this Skip must be removed") + + created, err := testutils.Client.NewPrivateLinkCreate(). + Name("go_sdk_private_link_test"). + Service("SOURCE"). + Region("GCP_US_EAST4"). + CustomConfig(&map[string]interface{}{ + "connection_service_name": "test" + }). + DoCustom(context.Background()) + + if err != nil { + t.Logf("%+v\n", created) + t.Error(err) + } + + testutils.AssertEqual(t, created.Code, "Success") + testutils.AssertNotEmpty(t, created.Message) + testutils.AssertEqual(t, created.Data.Name, "go_sdk_private_link_test") + testutils.AssertNotEmpty(t, created.Data.Service) + testutils.AssertNotEmpty(t, created.Data.Region) + testutils.AssertNotEmpty(t, created.Data.CloudProvider) + testutils.AssertEqual(t, created.Data.Config["connection_service_name"], "test") + + t.Cleanup(func() { + testutils.DeletePrivateLink(t, created.Data.Id) + }) +} \ No newline at end of file From b6e1b0c470bada1d7314b8788021e0685e8fc54f Mon Sep 17 00:00:00 2001 From: Aleksandr Boldyrev Date: Mon, 4 Nov 2024 11:52:38 +0100 Subject: [PATCH 03/12] fix --- CHANGELOG.md | 7 ++++++- client.go | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b966d44..6c92288 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [Unreleased](https://github.com/fivetran/go-fivetran/compare/v1.0.3...HEAD) +## [Unreleased](https://github.com/fivetran/go-fivetran/compare/v1.0.4...HEAD) + +## [1.0.4](https://github.com/fivetran/go-fivetran/compare/v1.0.3...v1.0.4) + +## Added +- Fix `PrivateLinkCreateService.Do` with `PrivateLinkCreateService.ConfigCustom` ## [1.0.3](https://github.com/fivetran/go-fivetran/compare/v1.0.2...v1.0.3) diff --git a/client.go b/client.go index f437bf6..84c46f5 100644 --- a/client.go +++ b/client.go @@ -37,7 +37,7 @@ const defaultBaseURL = "https://api.fivetran.com/v1" const restAPIv2 = "application/json;version=2" // WARNING: Update Agent version on each release! -const defaultUserAgent = "Go-Fivetran/1.0.2" +const defaultUserAgent = "Go-Fivetran/1.0.4" // New receives API Key and API Secret, and returns a new Client with the // default HTTP client From f2f128e96793065540a1d804e19d47fe1b445e1a Mon Sep 17 00:00:00 2001 From: Aleksandr Boldyrev Date: Mon, 4 Nov 2024 11:56:05 +0100 Subject: [PATCH 04/12] Update private_link_create_test.go --- tests/e2e/private_link_create_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/private_link_create_test.go b/tests/e2e/private_link_create_test.go index d2472c9..2816bd8 100644 --- a/tests/e2e/private_link_create_test.go +++ b/tests/e2e/private_link_create_test.go @@ -45,7 +45,7 @@ func TestNewPrivateLinkCustomCreateE2E(t *testing.T) { Service("SOURCE"). Region("GCP_US_EAST4"). CustomConfig(&map[string]interface{}{ - "connection_service_name": "test" + "connection_service_name": "test", }). DoCustom(context.Background()) From 169b900ba25b06400a8515fe8ac7b9ef7339e3be Mon Sep 17 00:00:00 2001 From: Aleksandr Boldyrev Date: Mon, 4 Nov 2024 11:58:04 +0100 Subject: [PATCH 05/12] Update private_link_create_test.go --- tests/e2e/private_link_create_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/private_link_create_test.go b/tests/e2e/private_link_create_test.go index 2816bd8..7c371b1 100644 --- a/tests/e2e/private_link_create_test.go +++ b/tests/e2e/private_link_create_test.go @@ -44,7 +44,7 @@ func TestNewPrivateLinkCustomCreateE2E(t *testing.T) { Name("go_sdk_private_link_test"). Service("SOURCE"). Region("GCP_US_EAST4"). - CustomConfig(&map[string]interface{}{ + ConfigCustom(&map[string]interface{}{ "connection_service_name": "test", }). DoCustom(context.Background()) From 11b56dd8a50bf8700bf57cabe3a8fe8b5c820785 Mon Sep 17 00:00:00 2001 From: Aleksandr Boldyrev Date: Mon, 4 Nov 2024 12:13:59 +0100 Subject: [PATCH 06/12] Fix --- test_utils/test_utils.go | 2 +- tests/e2e/private_link_create_test.go | 4 ++-- tests/e2e/private_link_delete_test.go | 2 +- tests/e2e/private_link_details_test.go | 2 +- tests/e2e/private_link_list_test.go | 2 +- tests/e2e/private_link_modify_test.go | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test_utils/test_utils.go b/test_utils/test_utils.go index 90f3aa1..1921a16 100644 --- a/test_utils/test_utils.go +++ b/test_utils/test_utils.go @@ -746,7 +746,7 @@ func CreatePrivateLink(t *testing.T) string { t.Helper() created, err := Client.NewPrivateLinkCreate(). Name("go_sdk_private_link_internal"). - Service("SOURCE"). + Service("SOURCE_GCP"). Region("GCP_US_EAST4"). Config(fivetran.NewPrivateLinkConfig(). ConnectionServiceName("test")). diff --git a/tests/e2e/private_link_create_test.go b/tests/e2e/private_link_create_test.go index 7c371b1..6caab8f 100644 --- a/tests/e2e/private_link_create_test.go +++ b/tests/e2e/private_link_create_test.go @@ -13,7 +13,7 @@ func TestNewPrivateLinkCreateE2E(t *testing.T) { created, err := testutils.Client.NewPrivateLinkCreate(). Name("go_sdk_private_link_test"). - Service("SOURCE"). + Service("SOURCE_GCP"). Region("GCP_US_EAST4"). Config(fivetran.NewPrivateLinkConfig(). ConnectionServiceName("test")). @@ -42,7 +42,7 @@ func TestNewPrivateLinkCustomCreateE2E(t *testing.T) { created, err := testutils.Client.NewPrivateLinkCreate(). Name("go_sdk_private_link_test"). - Service("SOURCE"). + Service("SOURCE_GCP"). Region("GCP_US_EAST4"). ConfigCustom(&map[string]interface{}{ "connection_service_name": "test", diff --git a/tests/e2e/private_link_delete_test.go b/tests/e2e/private_link_delete_test.go index 3cf2047..5334942 100644 --- a/tests/e2e/private_link_delete_test.go +++ b/tests/e2e/private_link_delete_test.go @@ -8,7 +8,7 @@ import ( ) func TestNewPrivateLinkDeleteE2E(t *testing.T) { - t.Skip("Private links have a strict limit on the number of requests per hour; to test changes in these modules, this Skip must be removed") + //t.Skip("Private links have a strict limit on the number of requests per hour; to test changes in these modules, this Skip must be removed") privateLinkId := testutils.CreatePrivateLink(t) diff --git a/tests/e2e/private_link_details_test.go b/tests/e2e/private_link_details_test.go index 9266235..a36fe40 100644 --- a/tests/e2e/private_link_details_test.go +++ b/tests/e2e/private_link_details_test.go @@ -8,7 +8,7 @@ import ( ) func TestPrivateLinkDetailsE2E(t *testing.T) { - t.Skip("Private links have a strict limit on the number of requests per hour; to test changes in these modules, this Skip must be removed") + //t.Skip("Private links have a strict limit on the number of requests per hour; to test changes in these modules, this Skip must be removed") linkId := testutils.CreatePrivateLink(t) diff --git a/tests/e2e/private_link_list_test.go b/tests/e2e/private_link_list_test.go index d2eb536..fb246c2 100644 --- a/tests/e2e/private_link_list_test.go +++ b/tests/e2e/private_link_list_test.go @@ -8,7 +8,7 @@ import ( ) func TestPrivateLinkListE2E(t *testing.T) { - t.Skip("Private links have a strict limit on the number of requests per hour; to test changes in these modules, this Skip must be removed") + //t.Skip("Private links have a strict limit on the number of requests per hour; to test changes in these modules, this Skip must be removed") linkId := testutils.CreatePrivateLink(t) diff --git a/tests/e2e/private_link_modify_test.go b/tests/e2e/private_link_modify_test.go index 2b42617..3487f48 100644 --- a/tests/e2e/private_link_modify_test.go +++ b/tests/e2e/private_link_modify_test.go @@ -9,7 +9,7 @@ import ( ) func TestNewPrivateLinkModifyE2E(t *testing.T) { - t.Skip("Private links have a strict limit on the number of requests per hour; to test changes in these modules, this Skip must be removed") + //t.Skip("Private links have a strict limit on the number of requests per hour; to test changes in these modules, this Skip must be removed") privateLinkId := testutils.CreateTempPrivateLink(t) From be2655f37a2f92cb6345c608e2e6b289f577ddaa Mon Sep 17 00:00:00 2001 From: Aleksandr Boldyrev Date: Mon, 4 Nov 2024 15:22:52 +0100 Subject: [PATCH 07/12] fix tests --- test_utils/test_utils.go | 2 +- tests/e2e/private_link_create_test.go | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test_utils/test_utils.go b/test_utils/test_utils.go index 1921a16..0dd28c2 100644 --- a/test_utils/test_utils.go +++ b/test_utils/test_utils.go @@ -745,7 +745,7 @@ func CreateExternalLogging(t *testing.T) string { func CreatePrivateLink(t *testing.T) string { t.Helper() created, err := Client.NewPrivateLinkCreate(). - Name("go_sdk_private_link_internal"). + Name("sdk_private_link_test2"). Service("SOURCE_GCP"). Region("GCP_US_EAST4"). Config(fivetran.NewPrivateLinkConfig(). diff --git a/tests/e2e/private_link_create_test.go b/tests/e2e/private_link_create_test.go index 6caab8f..f1538e3 100644 --- a/tests/e2e/private_link_create_test.go +++ b/tests/e2e/private_link_create_test.go @@ -12,7 +12,7 @@ func TestNewPrivateLinkCreateE2E(t *testing.T) { //t.Skip("Private links have a strict limit on the number of requests per hour; to test changes in these modules, this Skip must be removed") created, err := testutils.Client.NewPrivateLinkCreate(). - Name("go_sdk_private_link_test"). + Name("sdk_private_link_test"). Service("SOURCE_GCP"). Region("GCP_US_EAST4"). Config(fivetran.NewPrivateLinkConfig(). @@ -26,7 +26,7 @@ func TestNewPrivateLinkCreateE2E(t *testing.T) { testutils.AssertEqual(t, created.Code, "Success") testutils.AssertNotEmpty(t, created.Message) - testutils.AssertEqual(t, created.Data.Name, "go_sdk_private_link_test") + testutils.AssertEqual(t, created.Data.Name, "sdk_private_link_test") testutils.AssertNotEmpty(t, created.Data.Service) testutils.AssertNotEmpty(t, created.Data.Region) testutils.AssertNotEmpty(t, created.Data.CloudProvider) @@ -41,7 +41,7 @@ func TestNewPrivateLinkCustomCreateE2E(t *testing.T) { //t.Skip("Private links have a strict limit on the number of requests per hour; to test changes in these modules, this Skip must be removed") created, err := testutils.Client.NewPrivateLinkCreate(). - Name("go_sdk_private_link_test"). + Name("sdk_private_link_test"). Service("SOURCE_GCP"). Region("GCP_US_EAST4"). ConfigCustom(&map[string]interface{}{ @@ -56,7 +56,7 @@ func TestNewPrivateLinkCustomCreateE2E(t *testing.T) { testutils.AssertEqual(t, created.Code, "Success") testutils.AssertNotEmpty(t, created.Message) - testutils.AssertEqual(t, created.Data.Name, "go_sdk_private_link_test") + testutils.AssertEqual(t, created.Data.Name, "sdk_private_link_test") testutils.AssertNotEmpty(t, created.Data.Service) testutils.AssertNotEmpty(t, created.Data.Region) testutils.AssertNotEmpty(t, created.Data.CloudProvider) From 51a94ee5047a4fd842120e5ee21e066268cf98ab Mon Sep 17 00:00:00 2001 From: Aleksandr Boldyrev Date: Mon, 4 Nov 2024 15:40:05 +0100 Subject: [PATCH 08/12] fix --- test_utils/test_utils.go | 2 +- tests/e2e/private_link_create_test.go | 8 ++++---- tests/e2e/private_link_modify_test.go | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test_utils/test_utils.go b/test_utils/test_utils.go index 0dd28c2..cb4dd55 100644 --- a/test_utils/test_utils.go +++ b/test_utils/test_utils.go @@ -749,7 +749,7 @@ func CreatePrivateLink(t *testing.T) string { Service("SOURCE_GCP"). Region("GCP_US_EAST4"). Config(fivetran.NewPrivateLinkConfig(). - ConnectionServiceName("test")). + PrivateConnectionServiceId("test")). Do(context.Background()) if err != nil { diff --git a/tests/e2e/private_link_create_test.go b/tests/e2e/private_link_create_test.go index f1538e3..053df88 100644 --- a/tests/e2e/private_link_create_test.go +++ b/tests/e2e/private_link_create_test.go @@ -16,7 +16,7 @@ func TestNewPrivateLinkCreateE2E(t *testing.T) { Service("SOURCE_GCP"). Region("GCP_US_EAST4"). Config(fivetran.NewPrivateLinkConfig(). - ConnectionServiceName("test")). + PrivateConnectionServiceId("test")). Do(context.Background()) if err != nil { @@ -30,7 +30,7 @@ func TestNewPrivateLinkCreateE2E(t *testing.T) { testutils.AssertNotEmpty(t, created.Data.Service) testutils.AssertNotEmpty(t, created.Data.Region) testutils.AssertNotEmpty(t, created.Data.CloudProvider) - testutils.AssertEqual(t, created.Data.Config.ConnectionServiceName, "test") + testutils.AssertEqual(t, created.Data.Config.PrivateConnectionServiceId, "test") t.Cleanup(func() { testutils.DeletePrivateLink(t, created.Data.Id) @@ -45,7 +45,7 @@ func TestNewPrivateLinkCustomCreateE2E(t *testing.T) { Service("SOURCE_GCP"). Region("GCP_US_EAST4"). ConfigCustom(&map[string]interface{}{ - "connection_service_name": "test", + "private_connection_service_id": "test", }). DoCustom(context.Background()) @@ -60,7 +60,7 @@ func TestNewPrivateLinkCustomCreateE2E(t *testing.T) { testutils.AssertNotEmpty(t, created.Data.Service) testutils.AssertNotEmpty(t, created.Data.Region) testutils.AssertNotEmpty(t, created.Data.CloudProvider) - testutils.AssertEqual(t, created.Data.Config["connection_service_name"], "test") + testutils.AssertEqual(t, created.Data.Config["private_connection_service_id"], "test") t.Cleanup(func() { testutils.DeletePrivateLink(t, created.Data.Id) diff --git a/tests/e2e/private_link_modify_test.go b/tests/e2e/private_link_modify_test.go index 3487f48..6e5e779 100644 --- a/tests/e2e/private_link_modify_test.go +++ b/tests/e2e/private_link_modify_test.go @@ -15,7 +15,7 @@ func TestNewPrivateLinkModifyE2E(t *testing.T) { details, err := testutils.Client.NewPrivateLinkModify().PrivateLinkId(privateLinkId). Config(fivetran.NewPrivateLinkConfig(). - ConnectionServiceName("test2")). + PrivateConnectionServiceId("test2")). Do(context.Background()) if err != nil { @@ -25,5 +25,5 @@ func TestNewPrivateLinkModifyE2E(t *testing.T) { testutils.AssertEqual(t, details.Code, "Success") testutils.AssertNotEmpty(t, details.Message) - testutils.AssertEqual(t, details.Data.Config.ConnectionServiceName, "test2") + testutils.AssertEqual(t, details.Data.Config.PrivateConnectionServiceId, "test2") } \ No newline at end of file From be8adfd888761b951be32fb6adecaa37fd02eb07 Mon Sep 17 00:00:00 2001 From: Aleksandr Boldyrev Date: Mon, 4 Nov 2024 16:11:27 +0100 Subject: [PATCH 09/12] fix --- test_utils/test_utils.go | 3 ++- tests/e2e/fivetran_test.go | 4 ++++ tests/e2e/private_link_create_test.go | 12 ++++++------ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/test_utils/test_utils.go b/test_utils/test_utils.go index cb4dd55..6a02aec 100644 --- a/test_utils/test_utils.go +++ b/test_utils/test_utils.go @@ -744,8 +744,9 @@ func CreateExternalLogging(t *testing.T) string { /* Private Links */ func CreatePrivateLink(t *testing.T) string { t.Helper() + suffix := strconv.Itoa(seededRand.Int()) created, err := Client.NewPrivateLinkCreate(). - Name("sdk_private_link_test2"). + Name(suffix). Service("SOURCE_GCP"). Region("GCP_US_EAST4"). Config(fivetran.NewPrivateLinkConfig(). diff --git a/tests/e2e/fivetran_test.go b/tests/e2e/fivetran_test.go index 5c823fb..16d6bd3 100644 --- a/tests/e2e/fivetran_test.go +++ b/tests/e2e/fivetran_test.go @@ -2,8 +2,12 @@ package fivetran_test import ( testutils "github.com/fivetran/go-fivetran/test_utils" + "math/rand" + "time" ) +var seededRand *rand.Rand = rand.New(rand.NewSource(time.Now().UnixNano())) + func init() { testutils.InitE2E() } diff --git a/tests/e2e/private_link_create_test.go b/tests/e2e/private_link_create_test.go index 053df88..6831fc4 100644 --- a/tests/e2e/private_link_create_test.go +++ b/tests/e2e/private_link_create_test.go @@ -10,9 +10,9 @@ import ( func TestNewPrivateLinkCreateE2E(t *testing.T) { //t.Skip("Private links have a strict limit on the number of requests per hour; to test changes in these modules, this Skip must be removed") - + suffix := strconv.Itoa(seededRand.Int()) created, err := testutils.Client.NewPrivateLinkCreate(). - Name("sdk_private_link_test"). + Name(suffix). Service("SOURCE_GCP"). Region("GCP_US_EAST4"). Config(fivetran.NewPrivateLinkConfig(). @@ -26,7 +26,7 @@ func TestNewPrivateLinkCreateE2E(t *testing.T) { testutils.AssertEqual(t, created.Code, "Success") testutils.AssertNotEmpty(t, created.Message) - testutils.AssertEqual(t, created.Data.Name, "sdk_private_link_test") + testutils.AssertEqual(t, created.Data.Name, suffix) testutils.AssertNotEmpty(t, created.Data.Service) testutils.AssertNotEmpty(t, created.Data.Region) testutils.AssertNotEmpty(t, created.Data.CloudProvider) @@ -39,9 +39,9 @@ func TestNewPrivateLinkCreateE2E(t *testing.T) { func TestNewPrivateLinkCustomCreateE2E(t *testing.T) { //t.Skip("Private links have a strict limit on the number of requests per hour; to test changes in these modules, this Skip must be removed") - + suffix := strconv.Itoa(seededRand.Int()) created, err := testutils.Client.NewPrivateLinkCreate(). - Name("sdk_private_link_test"). + Name(suffix). Service("SOURCE_GCP"). Region("GCP_US_EAST4"). ConfigCustom(&map[string]interface{}{ @@ -56,7 +56,7 @@ func TestNewPrivateLinkCustomCreateE2E(t *testing.T) { testutils.AssertEqual(t, created.Code, "Success") testutils.AssertNotEmpty(t, created.Message) - testutils.AssertEqual(t, created.Data.Name, "sdk_private_link_test") + testutils.AssertEqual(t, created.Data.Name, suffix) testutils.AssertNotEmpty(t, created.Data.Service) testutils.AssertNotEmpty(t, created.Data.Region) testutils.AssertNotEmpty(t, created.Data.CloudProvider) From 3fe7d5b39372e6bef0524172a553e1d81aa39d7f Mon Sep 17 00:00:00 2001 From: Aleksandr Boldyrev Date: Mon, 4 Nov 2024 16:42:50 +0100 Subject: [PATCH 10/12] fix --- test_utils/test_utils.go | 5 ++++- tests/e2e/fivetran_test.go | 4 ---- tests/e2e/private_link_create_test.go | 5 +++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test_utils/test_utils.go b/test_utils/test_utils.go index 6a02aec..0f4cb07 100644 --- a/test_utils/test_utils.go +++ b/test_utils/test_utils.go @@ -11,7 +11,9 @@ import ( "os" "reflect" "testing" + "strconv" "time" + "math/rand" "github.com/fivetran/go-fivetran" "github.com/fivetran/go-fivetran/tests/mock" @@ -21,6 +23,7 @@ var Client *fivetran.Client var CertificateHash string var EncodedCertificate string +var SeededRand *rand.Rand = rand.New(rand.NewSource(time.Now().UnixNano())) // Tests should be re-written to not use a pre-defined user and group const ( @@ -744,7 +747,7 @@ func CreateExternalLogging(t *testing.T) string { /* Private Links */ func CreatePrivateLink(t *testing.T) string { t.Helper() - suffix := strconv.Itoa(seededRand.Int()) + suffix := strconv.Itoa(SeededRand.Int()) created, err := Client.NewPrivateLinkCreate(). Name(suffix). Service("SOURCE_GCP"). diff --git a/tests/e2e/fivetran_test.go b/tests/e2e/fivetran_test.go index 16d6bd3..5c823fb 100644 --- a/tests/e2e/fivetran_test.go +++ b/tests/e2e/fivetran_test.go @@ -2,12 +2,8 @@ package fivetran_test import ( testutils "github.com/fivetran/go-fivetran/test_utils" - "math/rand" - "time" ) -var seededRand *rand.Rand = rand.New(rand.NewSource(time.Now().UnixNano())) - func init() { testutils.InitE2E() } diff --git a/tests/e2e/private_link_create_test.go b/tests/e2e/private_link_create_test.go index 6831fc4..404be81 100644 --- a/tests/e2e/private_link_create_test.go +++ b/tests/e2e/private_link_create_test.go @@ -3,6 +3,7 @@ package fivetran_test import ( "context" "testing" + "strconv" "github.com/fivetran/go-fivetran" testutils "github.com/fivetran/go-fivetran/test_utils" @@ -10,7 +11,7 @@ import ( func TestNewPrivateLinkCreateE2E(t *testing.T) { //t.Skip("Private links have a strict limit on the number of requests per hour; to test changes in these modules, this Skip must be removed") - suffix := strconv.Itoa(seededRand.Int()) + suffix := strconv.Itoa(testutils.SeededRand.Int()) created, err := testutils.Client.NewPrivateLinkCreate(). Name(suffix). Service("SOURCE_GCP"). @@ -39,7 +40,7 @@ func TestNewPrivateLinkCreateE2E(t *testing.T) { func TestNewPrivateLinkCustomCreateE2E(t *testing.T) { //t.Skip("Private links have a strict limit on the number of requests per hour; to test changes in these modules, this Skip must be removed") - suffix := strconv.Itoa(seededRand.Int()) + suffix := strconv.Itoa(testutils.SeededRand.Int()) created, err := testutils.Client.NewPrivateLinkCreate(). Name(suffix). Service("SOURCE_GCP"). From e1a3b0971cb9b05f4ec1d4b8fcb0e92d99ab5b56 Mon Sep 17 00:00:00 2001 From: Aleksandr Boldyrev Date: Mon, 4 Nov 2024 20:06:10 +0100 Subject: [PATCH 11/12] comment passed PL tests --- tests/e2e/private_link_create_test.go | 4 ++-- tests/e2e/private_link_delete_test.go | 2 +- tests/e2e/private_link_details_test.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/e2e/private_link_create_test.go b/tests/e2e/private_link_create_test.go index 404be81..b60f9ea 100644 --- a/tests/e2e/private_link_create_test.go +++ b/tests/e2e/private_link_create_test.go @@ -10,7 +10,7 @@ import ( ) func TestNewPrivateLinkCreateE2E(t *testing.T) { - //t.Skip("Private links have a strict limit on the number of requests per hour; to test changes in these modules, this Skip must be removed") + t.Skip("Passed in previous runs. Private links have a strict limit on the number of requests per hour; to test changes in these modules, this Skip must be removed") suffix := strconv.Itoa(testutils.SeededRand.Int()) created, err := testutils.Client.NewPrivateLinkCreate(). Name(suffix). @@ -39,7 +39,7 @@ func TestNewPrivateLinkCreateE2E(t *testing.T) { } func TestNewPrivateLinkCustomCreateE2E(t *testing.T) { - //t.Skip("Private links have a strict limit on the number of requests per hour; to test changes in these modules, this Skip must be removed") + t.Skip("Passed in previous runs. Private links have a strict limit on the number of requests per hour; to test changes in these modules, this Skip must be removed") suffix := strconv.Itoa(testutils.SeededRand.Int()) created, err := testutils.Client.NewPrivateLinkCreate(). Name(suffix). diff --git a/tests/e2e/private_link_delete_test.go b/tests/e2e/private_link_delete_test.go index 5334942..cee1627 100644 --- a/tests/e2e/private_link_delete_test.go +++ b/tests/e2e/private_link_delete_test.go @@ -8,7 +8,7 @@ import ( ) func TestNewPrivateLinkDeleteE2E(t *testing.T) { - //t.Skip("Private links have a strict limit on the number of requests per hour; to test changes in these modules, this Skip must be removed") + t.Skip("Passed in previous runs. Private links have a strict limit on the number of requests per hour; to test changes in these modules, this Skip must be removed") privateLinkId := testutils.CreatePrivateLink(t) diff --git a/tests/e2e/private_link_details_test.go b/tests/e2e/private_link_details_test.go index a36fe40..22b6720 100644 --- a/tests/e2e/private_link_details_test.go +++ b/tests/e2e/private_link_details_test.go @@ -8,7 +8,7 @@ import ( ) func TestPrivateLinkDetailsE2E(t *testing.T) { - //t.Skip("Private links have a strict limit on the number of requests per hour; to test changes in these modules, this Skip must be removed") + t.Skip("Passed in previous runs. Private links have a strict limit on the number of requests per hour; to test changes in these modules, this Skip must be removed") linkId := testutils.CreatePrivateLink(t) From b049d1bc2f2ae15e30eb2fad6f61df16e53be2c9 Mon Sep 17 00:00:00 2001 From: Aleksandr Boldyrev Date: Tue, 5 Nov 2024 15:31:30 +0100 Subject: [PATCH 12/12] fix tests --- tests/e2e/private_link_details_test.go | 4 ++-- tests/e2e/private_link_list_test.go | 17 ++++++++++------- tests/e2e/private_link_modify_test.go | 8 +++++--- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/tests/e2e/private_link_details_test.go b/tests/e2e/private_link_details_test.go index 22b6720..e3d93d2 100644 --- a/tests/e2e/private_link_details_test.go +++ b/tests/e2e/private_link_details_test.go @@ -22,8 +22,8 @@ func TestPrivateLinkDetailsE2E(t *testing.T) { testutils.AssertEqual(t, result.Data.Id, linkId) testutils.AssertNotEmpty(t, result.Data.Name) testutils.AssertNotEmpty(t, result.Data.AccountId) - testutils.AssertNotEmpty(t, result.Data.Region) - testutils.AssertNotEmpty(t, result.Data.Service) + testutils.AssertEqual(t, result.Data.Region, "GCP_US_EAST4") + testutils.AssertEqual(t, result.Data.Service, "SOURCE_GCP") testutils.AssertNotEmpty(t, result.Data.CreatedAt) testutils.AssertNotEmpty(t, result.Data.CreatedBy) diff --git a/tests/e2e/private_link_list_test.go b/tests/e2e/private_link_list_test.go index fb246c2..5dc74d8 100644 --- a/tests/e2e/private_link_list_test.go +++ b/tests/e2e/private_link_list_test.go @@ -19,13 +19,16 @@ func TestPrivateLinkListE2E(t *testing.T) { } testutils.AssertEqual(t, result.Code, "Success") - testutils.AssertEqual(t, result.Data.Items[0].Id, linkId) - testutils.AssertNotEmpty(t, result.Data.Items[0].AccountId) - testutils.AssertNotEmpty(t, result.Data.Items[0].Region) - testutils.AssertNotEmpty(t, result.Data.Items[0].Service) - testutils.AssertNotEmpty(t, result.Data.Items[0].CreatedAt) - testutils.AssertNotEmpty(t, result.Data.Items[0].CreatedBy) - testutils.AssertNotEmpty(t, result.Data.Items[0].Name) + for _, v := range result.Data.Items { + if v.Id == linkId { + testutils.AssertNotEmpty(t, v.AccountId) + testutils.AssertEqual(t, v.Region, "GCP_US_EAST4") + testutils.AssertEqual(t, v.Service, "SOURCE_GCP") + testutils.AssertNotEmpty(t, v.CreatedAt) + testutils.AssertNotEmpty(t, v.CreatedBy) + testutils.AssertNotEmpty(t, v.Name) + } + } t.Cleanup(func() { testutils.DeletePrivateLink(t, linkId) }) } diff --git a/tests/e2e/private_link_modify_test.go b/tests/e2e/private_link_modify_test.go index 6e5e779..b3cf9bf 100644 --- a/tests/e2e/private_link_modify_test.go +++ b/tests/e2e/private_link_modify_test.go @@ -20,10 +20,12 @@ func TestNewPrivateLinkModifyE2E(t *testing.T) { if err != nil { t.Logf("%+v\n", details) - t.Error(err) + if details.Code != "IllegalState" { + t.Error(err) + } } - testutils.AssertEqual(t, details.Code, "Success") + // Private link in CREATING state is not allowed to perform any operation + testutils.AssertEqual(t, details.Code, "IllegalState") testutils.AssertNotEmpty(t, details.Message) - testutils.AssertEqual(t, details.Data.Config.PrivateConnectionServiceId, "test2") } \ No newline at end of file