X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=E2Manager%2Fmanagers%2Fe2t_association_manager_test.go;h=d515cd558ebaf1e99f29372869aeffa4d94c21f7;hb=313355950ec536c37ea40e630b0d81e4e674e07c;hp=73be9059febba83967ce05b260dee70dcc5fd0db;hpb=a75da9a56d61ca4754650d44a54bbf0b04f610d1;p=ric-plt%2Fe2mgr.git diff --git a/E2Manager/managers/e2t_association_manager_test.go b/E2Manager/managers/e2t_association_manager_test.go index 73be905..d515cd5 100644 --- a/E2Manager/managers/e2t_association_manager_test.go +++ b/E2Manager/managers/e2t_association_manager_test.go @@ -71,10 +71,10 @@ func mockHttpClient(httpClientMock *mocks.HttpClientMock, apiSuffix string, isSu func TestAssociateRanSuccess(t *testing.T) { manager, readerMock, writerMock, httpClientMock := initE2TAssociationManagerTest(t) mockHttpClient(httpClientMock, clients.AssociateRanToE2TInstanceApiSuffix, true) - nb := &entities.NodebInfo{RanName: RanName, AssociatedE2TInstanceAddress: "", ConnectionAttempts: 1} + nb := &entities.NodebInfo{RanName: RanName, AssociatedE2TInstanceAddress: ""} updatedNb := *nb - updatedNb.ConnectionAttempts = 0 updatedNb.AssociatedE2TInstanceAddress = E2TAddress + updatedNb.ConnectionStatus = entities.ConnectionStatus_CONNECTED writerMock.On("UpdateNodebInfo", &updatedNb).Return(nil) e2tInstance := &entities.E2TInstance{Address: E2TAddress} readerMock.On("GetE2TInstance", E2TAddress).Return(e2tInstance, nil) @@ -91,15 +91,15 @@ func TestAssociateRanSuccess(t *testing.T) { } func TestAssociateRanRoutingManagerError(t *testing.T) { - manager, readerMock, writerMock, httpClientMock := initE2TAssociationManagerTest(t) + manager, _, writerMock, httpClientMock := initE2TAssociationManagerTest(t) mockHttpClient(httpClientMock, clients.AssociateRanToE2TInstanceApiSuffix, false) + nb := &entities.NodebInfo{RanName: RanName, AssociatedE2TInstanceAddress: ""} + writerMock.On("UpdateNodebInfo", nb).Return(nil) - nb := &entities.NodebInfo{RanName: RanName, AssociatedE2TInstanceAddress: "", ConnectionAttempts: 1} err := manager.AssociateRan(E2TAddress, nb) assert.NotNil(t, err) assert.IsType(t, &e2managererrors.RoutingManagerError{}, err) - readerMock.AssertExpectations(t) writerMock.AssertExpectations(t) httpClientMock.AssertExpectations(t) } @@ -107,10 +107,10 @@ func TestAssociateRanRoutingManagerError(t *testing.T) { func TestAssociateRanUpdateNodebError(t *testing.T) { manager, readerMock, writerMock, httpClientMock := initE2TAssociationManagerTest(t) mockHttpClient(httpClientMock, clients.AssociateRanToE2TInstanceApiSuffix, true) - nb := &entities.NodebInfo{RanName: RanName, AssociatedE2TInstanceAddress: "", ConnectionAttempts: 1} + nb := &entities.NodebInfo{RanName: RanName, AssociatedE2TInstanceAddress: ""} updatedNb := *nb - updatedNb.ConnectionAttempts = 0 updatedNb.AssociatedE2TInstanceAddress = E2TAddress + updatedNb.ConnectionStatus = entities.ConnectionStatus_CONNECTED writerMock.On("UpdateNodebInfo", &updatedNb).Return(e2managererrors.NewRnibDbError()) err := manager.AssociateRan(E2TAddress, nb) @@ -125,10 +125,10 @@ func TestAssociateRanUpdateNodebError(t *testing.T) { func TestAssociateRanGetE2tInstanceError(t *testing.T) { manager, readerMock, writerMock, httpClientMock := initE2TAssociationManagerTest(t) mockHttpClient(httpClientMock, clients.AssociateRanToE2TInstanceApiSuffix, true) - nb := &entities.NodebInfo{RanName: RanName, AssociatedE2TInstanceAddress: "", ConnectionAttempts: 1} + nb := &entities.NodebInfo{RanName: RanName, AssociatedE2TInstanceAddress: ""} updatedNb := *nb - updatedNb.ConnectionAttempts = 0 updatedNb.AssociatedE2TInstanceAddress = E2TAddress + updatedNb.ConnectionStatus = entities.ConnectionStatus_CONNECTED writerMock.On("UpdateNodebInfo", &updatedNb).Return(nil) var e2tInstance *entities.E2TInstance readerMock.On("GetE2TInstance", E2TAddress).Return(e2tInstance, errors.New("test")) @@ -145,10 +145,10 @@ func TestAssociateRanGetE2tInstanceError(t *testing.T) { func TestAssociateRanSaveE2tInstanceError(t *testing.T) { manager, readerMock, writerMock, httpClientMock := initE2TAssociationManagerTest(t) mockHttpClient(httpClientMock, clients.AssociateRanToE2TInstanceApiSuffix, true) - nb := &entities.NodebInfo{RanName: RanName, AssociatedE2TInstanceAddress: "", ConnectionAttempts: 1} + nb := &entities.NodebInfo{RanName: RanName, AssociatedE2TInstanceAddress: ""} updatedNb := *nb - updatedNb.ConnectionAttempts = 0 updatedNb.AssociatedE2TInstanceAddress = E2TAddress + updatedNb.ConnectionStatus = entities.ConnectionStatus_CONNECTED writerMock.On("UpdateNodebInfo", &updatedNb).Return(nil) e2tInstance := &entities.E2TInstance{Address: E2TAddress} readerMock.On("GetE2TInstance", E2TAddress).Return(e2tInstance, nil) @@ -168,7 +168,7 @@ func TestAssociateRanSaveE2tInstanceError(t *testing.T) { func TestDissociateRanSuccess(t *testing.T) { manager, readerMock, writerMock, httpClientMock := initE2TAssociationManagerTest(t) mockHttpClient(httpClientMock, clients.DissociateRanE2TInstanceApiSuffix, true) - nb := &entities.NodebInfo{RanName: RanName, AssociatedE2TInstanceAddress: E2TAddress, ConnectionAttempts: 1} + nb := &entities.NodebInfo{RanName: RanName, AssociatedE2TInstanceAddress: E2TAddress} readerMock.On("GetNodeb", RanName).Return(nb, nil) updatedNb := *nb updatedNb.AssociatedE2TInstanceAddress = "" @@ -204,7 +204,7 @@ func TestDissociateRanGetNodebError(t *testing.T) { func TestDissociateRanUpdateNodebError(t *testing.T) { manager, readerMock, writerMock, httpClientMock := initE2TAssociationManagerTest(t) - nb := &entities.NodebInfo{RanName: RanName, AssociatedE2TInstanceAddress: E2TAddress, ConnectionAttempts: 1} + nb := &entities.NodebInfo{RanName: RanName, AssociatedE2TInstanceAddress: E2TAddress} readerMock.On("GetNodeb", RanName).Return(nb, nil) updatedNb := *nb updatedNb.AssociatedE2TInstanceAddress = "" @@ -221,7 +221,7 @@ func TestDissociateRanUpdateNodebError(t *testing.T) { func TestDissociateRanGetE2tInstanceError(t *testing.T) { manager, readerMock, writerMock, httpClientMock := initE2TAssociationManagerTest(t) - nb := &entities.NodebInfo{RanName: RanName, AssociatedE2TInstanceAddress: E2TAddress, ConnectionAttempts: 1} + nb := &entities.NodebInfo{RanName: RanName, AssociatedE2TInstanceAddress: E2TAddress} readerMock.On("GetNodeb", RanName).Return(nb, nil) updatedNb := *nb updatedNb.AssociatedE2TInstanceAddress = "" @@ -240,7 +240,7 @@ func TestDissociateRanGetE2tInstanceError(t *testing.T) { func TestDissociateRanSaveE2tInstanceError(t *testing.T) { manager, readerMock, writerMock, httpClientMock := initE2TAssociationManagerTest(t) - nb := &entities.NodebInfo{RanName: RanName, AssociatedE2TInstanceAddress: E2TAddress, ConnectionAttempts: 1} + nb := &entities.NodebInfo{RanName: RanName, AssociatedE2TInstanceAddress: E2TAddress} readerMock.On("GetNodeb", RanName).Return(nb, nil) updatedNb := *nb updatedNb.AssociatedE2TInstanceAddress = "" @@ -264,7 +264,7 @@ func TestDissociateRanSaveE2tInstanceError(t *testing.T) { func TestDissociateRanRoutingManagerError(t *testing.T) { manager, readerMock, writerMock, httpClientMock := initE2TAssociationManagerTest(t) mockHttpClient(httpClientMock, clients.DissociateRanE2TInstanceApiSuffix, false) - nb := &entities.NodebInfo{RanName: RanName, AssociatedE2TInstanceAddress: E2TAddress, ConnectionAttempts: 1} + nb := &entities.NodebInfo{RanName: RanName, AssociatedE2TInstanceAddress: E2TAddress} readerMock.On("GetNodeb", RanName).Return(nb, nil) updatedNb := *nb updatedNb.AssociatedE2TInstanceAddress = ""