From 1a358dd25552f59c4b912feeb349d397a80d5011 Mon Sep 17 00:00:00 2001 From: Denis Arh Date: Tue, 9 Aug 2022 20:52:21 +0200 Subject: [PATCH] Fix broken system tests when updating primary conn We no longer compare config changes on primary connection Just override the values from the old one --- system/service/dal_connection.go | 15 ++++++--------- tests/system/dal_connection_crud_test.go | 8 ++++++++ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/system/service/dal_connection.go b/system/service/dal_connection.go index 73b055858..16bbe779b 100644 --- a/system/service/dal_connection.go +++ b/system/service/dal_connection.go @@ -3,7 +3,6 @@ package service import ( "context" "fmt" - "reflect" "regexp" "github.com/cortezaproject/corteza-server/pkg/errors" @@ -139,14 +138,12 @@ func (svc *dalConnection) Update(ctx context.Context, upd *types.DalConnection) // validate { if old.Type == types.DalPrimaryConnectionResourceType { - if !reflect.DeepEqual(old.Config.Connection, upd.Config.Connection) { - // @todo err - return fmt.Errorf("can not update connection parameters for primary connection") - } - - if old.Type != upd.Type { - return fmt.Errorf("can not update type for primary connection") - } + // when primary connection is updated, + // ignore configuration changes + // + // see Test_dal_connection_update_primary + // for more details + upd.Config = old.Config } } diff --git a/tests/system/dal_connection_crud_test.go b/tests/system/dal_connection_crud_test.go index e95d77a56..9b1e8c90d 100644 --- a/tests/system/dal_connection_crud_test.go +++ b/tests/system/dal_connection_crud_test.go @@ -191,6 +191,14 @@ func Test_dal_connection_update_primary(t *testing.T) { helpers.AllowMe(h, types.DalConnectionRbacResource(0), "update") + // a bit of a problem with testing primary connection update + // + // when using (for running tests) anything else than connection params specified + // in the generic.json scenario, the update will fail + // with "can not update connection parameters for primary ..." + // + // see Update on dalConnection service. + h.apiInit(). Put(fmt.Sprintf("/dal/connections/%d", sl.ID)). Header("Accept", "application/json").