fixes for local tests

This commit is contained in:
Radu Ioan Fericean
2015-05-26 20:55:19 +03:00
parent 34b0e86811
commit 3f3cb5b3ce
4 changed files with 13 additions and 17 deletions

View File

@@ -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)
}

View File

@@ -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])

View File

@@ -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])

View File

@@ -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) {