mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-25 00:58:45 +05:00
fixes for local tests
This commit is contained in:
@@ -61,9 +61,11 @@ func (dbr *DbReader) WriteToDatabase(flush, verbose bool) (err error) {
|
||||
|
||||
func (dbr *DbReader) LoadDestinations() (err error) {
|
||||
tpDests, err := dbr.storDb.GetTpDestinations(dbr.tpid, "")
|
||||
if err == nil {
|
||||
return
|
||||
if err != nil {
|
||||
log.Print("ERRRR: ", err)
|
||||
return err
|
||||
}
|
||||
log.Print("TpDESTS: ", tpDests)
|
||||
return dbr.tp.LoadDestinations(tpDests)
|
||||
}
|
||||
|
||||
|
||||
@@ -89,7 +89,9 @@ func TestMySQLSetGetTPDestination(t *testing.T) {
|
||||
if err := mysqlDb.SetTPDestination(TEST_SQL, dst); err != nil {
|
||||
t.Error(err.Error())
|
||||
}
|
||||
if dsts, err := mysqlDb.GetTpDestinations(TEST_SQL, TEST_SQL); err != nil {
|
||||
storData, err := mysqlDb.GetTpDestinations(TEST_SQL, TEST_SQL)
|
||||
dsts := TpDestinations(storData).GetDestinations()
|
||||
if err != nil {
|
||||
t.Error(err.Error())
|
||||
} else if !reflect.DeepEqual(dst, dsts[TEST_SQL]) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", dst, dsts[TEST_SQL])
|
||||
|
||||
@@ -89,7 +89,9 @@ func TestPSQLSetGetTPDestination(t *testing.T) {
|
||||
if err := psqlDb.SetTPDestination(TEST_SQL, dst); err != nil {
|
||||
t.Error(err.Error())
|
||||
}
|
||||
if dsts, err := psqlDb.GetTpDestinations(TEST_SQL, TEST_SQL); err != nil {
|
||||
storData, err := psqlDb.GetTpDestinations(TEST_SQL, TEST_SQL)
|
||||
dsts := TpDestinations(storData).GetDestinations()
|
||||
if err != nil {
|
||||
t.Error(err.Error())
|
||||
} else if len(dst.Prefixes) != len(dsts[TEST_SQL].Prefixes) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", dst, dsts[TEST_SQL])
|
||||
|
||||
@@ -1186,9 +1186,8 @@ func (self *SQLStorage) RemStoredCdrs(cgrIds []string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SQLStorage) GetTpDestinations(tpid, tag string) (map[string]*Destination, error) {
|
||||
dests := make(map[string]*Destination)
|
||||
var tpDests []TpDestination
|
||||
func (self *SQLStorage) GetTpDestinations(tpid, tag string) ([]*TpDestination, error) {
|
||||
var tpDests []*TpDestination
|
||||
q := self.db.Where("tpid = ?", tpid)
|
||||
if len(tag) != 0 {
|
||||
q = q.Where("tag = ?", tag)
|
||||
@@ -1197,16 +1196,7 @@ func (self *SQLStorage) GetTpDestinations(tpid, tag string) (map[string]*Destina
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, tpDest := range tpDests {
|
||||
var dest *Destination
|
||||
var found bool
|
||||
if dest, found = dests[tpDest.Tag]; !found {
|
||||
dest = &Destination{Id: tpDest.Tag}
|
||||
dests[tpDest.Tag] = dest
|
||||
}
|
||||
dest.AddPrefix(tpDest.Prefix)
|
||||
}
|
||||
return dests, nil
|
||||
return tpDests, nil
|
||||
}
|
||||
|
||||
func (self *SQLStorage) GetTpRates(tpid, tag string) (map[string]*utils.TPRate, error) {
|
||||
|
||||
Reference in New Issue
Block a user