rNibErr := w.UpdateNodebInfo(nodebInfo)
assert.NotNil(t, rNibErr)
- assert.Equal(t, common.VALIDATION_ERROR, rNibErr.GetCode())
+ assert.IsType(t, &common.ValidationError{}, rNibErr)
}
func TestUpdateNodebInfoMissingGlobalNbId(t *testing.T) {
nbIdentity := &entities.NbIdentity{InventoryName: name, GlobalNbId: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952a0a"}}
rNibErr := w.SaveNodeb(nbIdentity, &nb)
assert.NotNil(t, rNibErr)
- assert.Equal(t, common.VALIDATION_ERROR, rNibErr.GetCode())
- assert.Equal(t, "3 VALIDATION_ERROR - #utils.ValidateAndBuildCellIdKey - an empty cell id received", rNibErr.Error())
+ assert.IsType(t, &common.ValidationError{}, rNibErr)
+ assert.Equal(t, "#utils.ValidateAndBuildCellIdKey - an empty cell id received", rNibErr.Error())
}
func TestSaveEnbInventoryNameValidationFailure(t *testing.T) {
nbIdentity := &entities.NbIdentity{InventoryName: "", GlobalNbId: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952a0a"}}
rNibErr := w.SaveNodeb(nbIdentity, &nb)
assert.NotNil(t, rNibErr)
- assert.Equal(t, common.VALIDATION_ERROR, rNibErr.GetCode())
- assert.Equal(t, "3 VALIDATION_ERROR - #utils.ValidateAndBuildNodeBNameKey - an empty inventory name received", rNibErr.Error())
+ assert.IsType(t, &common.ValidationError{}, rNibErr)
+ assert.Equal(t, "#utils.ValidateAndBuildNodeBNameKey - an empty inventory name received", rNibErr.Error())
}
func TestSaveEnbOnClosedPool(t *testing.T) {
nbIdentity := &entities.NbIdentity{InventoryName: name, GlobalNbId: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952a0a"}}
rNibErr := w.SaveNodeb(nbIdentity, &nb)
assert.NotNil(t, rNibErr)
- assert.Equal(t, common.VALIDATION_ERROR, rNibErr.GetCode())
- assert.Equal(t, "3 VALIDATION_ERROR - #utils.ValidateAndBuildNrCellIdKey - an empty cell id received", rNibErr.Error())
+ assert.IsType(t, &common.ValidationError{}, rNibErr)
+ assert.Equal(t, "#utils.ValidateAndBuildNrCellIdKey - an empty cell id received", rNibErr.Error())
}
func TestSaveGnb(t *testing.T) {
err := w.SaveRanLoadInformation(inventoryName, nil)
assert.NotNil(t, err)
- assert.Equal(t, common.VALIDATION_ERROR, err.GetCode())
+ assert.IsType(t, &common.ValidationError{}, err)
}
func TestSaveRanLoadInformationSdlFailure(t *testing.T) {
rNibErr := w.SaveRanLoadInformation(inventoryName, ranLoadInformation)
assert.NotNil(t, rNibErr)
- assert.Equal(t, common.INTERNAL_ERROR, rNibErr.GetCode())
- assert.Equal(t, expectedErr, rNibErr.GetError())
+ assert.IsType(t, &common.InternalError{}, rNibErr)
}
func generateCellLoadInformation() *entities.CellLoadInformation {
writerPool = nil
initSdlInstanceMock(namespace, 1)
w := GetRNibWriter()
- expectedErr := common.NewValidationError(errors.New("#rNibWriter.saveNodeB - Unknown responding node type, entity: ip:\"localhost\" port:5656 "))
+ expectedErr := common.NewValidationError("#rNibWriter.saveNodeB - Unknown responding node type, entity: ip:\"localhost\" port:5656 ")
nbIdentity := &entities.NbIdentity{InventoryName: "name", GlobalNbId: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952a0a"}}
nb := &entities.NodebInfo{}
nb.Port = 5656
func TestGetRNibWriterPoolNotInitializedFailure(t *testing.T) {
writerPool = nil
- assert.Panics(t, func() { GetRNibWriter() })
+ assert.Panics(t, func() { GetRNibWriter().SaveNodeb(nil,nil) })
}
func TestGetRNibWriter(t *testing.T) {
writerPool = nil
initSdlInstanceMock(namespace, 1)
received := GetRNibWriter()
- assert.NotEmpty(t, received)
+ assert.Empty(t, received)
available, created := writerPool.Stats()
assert.Equal(t, 0, available, "number of available objects in the writerPool should be 0")
- assert.Equal(t, 1, created, "number of created objects in the writerPool should be 1")
+ assert.Equal(t, 0, created, "number of created objects in the writerPool should be 0")
writerPool.Close()
}
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, 2, created, "number of created objects in the writerPool should be 2")
+ assert.Equal(t, 0, created, "number of created objects in the writerPool should be 0")
var e error
instanceMock.On("Close").Return(e)
Close()
available, created = writerPool.Stats()
assert.Equal(t, 0, available, "number of available objects in the writerPool should be 0")
- assert.Equal(t, 0, created, "number of created objects in the writerPool should be 0")
}
func TestCloseOnClosedPoolFailure(t *testing.T) {
writerPool.Put(w1)
available, created := writerPool.Stats()
assert.Equal(t, 1, available, "number of available objects in the writerPool should be 1")
- assert.Equal(t, 1, created, "number of created objects in the writerPool should be 1")
+ assert.Equal(t, 0, created, "number of created objects in the writerPool should be 0")
var e error
instanceMock.On("Close").Return(e)
Close()
writerPool.Put(w1)
available, created := writerPool.Stats()
assert.Equal(t, 1, available, "number of available objects in the writerPool should be 1")
- assert.Equal(t, 1, created, "number of created objects in the writerPool should be 1")
+ assert.Equal(t, 0, created, "number of created objects in the writerPool should be 0")
e := errors.New("expected error")
instanceMock.On("Close").Return(e)
Close()
available, created = writerPool.Stats()
assert.Equal(t, 0, available, "number of available objects in the writerPool should be 0")
- assert.Equal(t, 0, created, "number of created objects in the writerPool should be 0")
}
func TestInit(t *testing.T) {