-func TestClose(t *testing.T) {
- writerPool = nil
- instanceMock := initSdlInstanceMock(namespace, 2)
- w1 := GetRNibWriter()
- w2 := GetRNibWriter()
- writerPool.Put(w1)
- writerPool.Put(w2)
- available, created := writerPool.Stats()
- assert.Equal(t, 2, available, "number of available objects in the writerPool should be 2")
- assert.Equal(t, 0, created, "number of created objects in the writerPool should be 0")
+func TestSaveE2TInstanceSdlFailure(t *testing.T) {
+ address := "10.10.2.15:9800"
+ loadKey, validationErr := common.ValidateAndBuildE2TInstanceKey(address)
+
+ if validationErr != nil {
+ t.Errorf("#rNibWriter_test.TestSaveE2TInstanceSdlFailure - Failed to build E2T Instance key. Error: %v", validationErr)
+ }
+
+ w, sdlInstanceMock := initSdlInstanceMock(namespace)
+
+ e2tInstance := generateE2tInstance(address)
+ data, err := json.Marshal(e2tInstance)
+
+ if err != nil {
+ t.Errorf("#rNibWriter_test.TestSaveE2TInstanceSdlFailure - Failed to marshal E2tInstance entity. Error: %v", err)
+ }
+
+ expectedErr := errors.New("expected error")
+ var setExpected []interface{}
+ setExpected = append(setExpected, loadKey, data)
+ sdlInstanceMock.On("Set", []interface{}{setExpected}).Return(expectedErr)
+
+ rNibErr := w.SaveE2TInstance(e2tInstance)
+ assert.NotNil(t, rNibErr)
+ assert.IsType(t, &common.InternalError{}, rNibErr)
+}
+
+func generateE2tInstance(address string) *entities.E2TInstance {
+ e2tInstance := entities.NewE2TInstance(address, "pod test")
+
+ e2tInstance.AssociatedRanList = []string{"test1", "test2"}
+
+ return e2tInstance
+}
+
+func TestSaveE2TAddressesSuccess(t *testing.T) {
+ address := "10.10.2.15:9800"
+ w, sdlInstanceMock := initSdlInstanceMock(namespace)
+
+ e2tAddresses := []string{address}
+ data, err := json.Marshal(e2tAddresses)
+
+ if err != nil {
+ t.Errorf("#rNibWriter_test.TestSaveE2TInfoListSuccess - Failed to marshal E2TInfoList. Error: %v", err)
+ }
+