cleanned all vet's warnings

This commit is contained in:
Radu Ioan Fericean
2015-02-05 21:54:28 +02:00
parent 8576d8f6fc
commit 39a85a76de
7 changed files with 35 additions and 33 deletions

View File

@@ -91,7 +91,7 @@ func TestBalanceMatchFilter(t *testing.T) {
mb1 := &Balance{Weight: 1, precision: 1, RatingSubject: "1", DestinationId: ""}
mb2 := &Balance{Weight: 1, precision: 1, RatingSubject: "", DestinationId: ""}
if !mb1.MatchFilter(mb2) {
t.Error("Match filter failure: %+v == %+v", mb1, mb2)
t.Errorf("Match filter failure: %+v == %+v", mb1, mb2)
}
}
@@ -99,7 +99,7 @@ func TestBalanceMatchFilterEmpty(t *testing.T) {
mb1 := &Balance{Weight: 1, precision: 1, RatingSubject: "1", DestinationId: ""}
mb2 := &Balance{}
if !mb1.MatchFilter(mb2) {
t.Error("Match filter failure: %+v == %+v", mb1, mb2)
t.Errorf("Match filter failure: %+v == %+v", mb1, mb2)
}
}
@@ -107,7 +107,7 @@ func TestBalanceMatchFilterId(t *testing.T) {
mb1 := &Balance{Id: "T1", Weight: 2, precision: 2, RatingSubject: "2", DestinationId: "NAT"}
mb2 := &Balance{Id: "T1", Weight: 1, precision: 1, RatingSubject: "1", DestinationId: ""}
if !mb1.MatchFilter(mb2) {
t.Error("Match filter failure: %+v == %+v", mb1, mb2)
t.Errorf("Match filter failure: %+v == %+v", mb1, mb2)
}
}
@@ -115,7 +115,7 @@ func TestBalanceMatchFilterDiffId(t *testing.T) {
mb1 := &Balance{Id: "T1", Weight: 1, precision: 1, RatingSubject: "1", DestinationId: ""}
mb2 := &Balance{Id: "T2", Weight: 1, precision: 1, RatingSubject: "1", DestinationId: ""}
if mb1.MatchFilter(mb2) {
t.Error("Match filter failure: %+v != %+v", mb1, mb2)
t.Errorf("Match filter failure: %+v != %+v", mb1, mb2)
}
}
@@ -235,6 +235,6 @@ func TestBalanceMatchActionTriggerSharedGroup(t *testing.T) {
func TestBalanceIsDefault(t *testing.T) {
b := &Balance{Weight: 0}
if !b.IsDefault() {
t.Errorf("Balance should be default: +v", b)
t.Errorf("Balance should be default: %+v", b)
}
}

View File

@@ -457,6 +457,7 @@ If the user has postpayed plan it returns -1.
*/
func (origCD *CallDescriptor) getMaxSessionDuration(origAcc *Account) (time.Duration, error) {
// clone the account for discarding chenges on debit dry run
//log.Printf("ORIG CD: %+v", origCD)
account := origAcc.Clone()
if account.AllowNegative {
return -1, nil
@@ -538,6 +539,7 @@ func (cd *CallDescriptor) debit(account *Account, dryRun bool) (cc *CallCost, er
if cd.TOR == "" {
cd.TOR = MINUTES
}
//log.Printf("Debit CD: %+v", cd)
cc, err = account.debitCreditBalance(cd, !dryRun, dryRun)
//log.Print("HERE: ", cc, err)
if err != nil {

View File

@@ -76,7 +76,7 @@ func TestStatsSimplifyCDR(t *testing.T) {
cdr.AnswerTime != qcdr.AnswerTime ||
cdr.Usage != qcdr.Usage ||
cdr.Cost != qcdr.Cost {
t.Error("Failed to simplify cdr: %+v", qcdr)
t.Errorf("Failed to simplify cdr: %+v", qcdr)
}
}
@@ -101,83 +101,83 @@ func TestAcceptCdr(t *testing.T) {
}
sq.conf = &CdrStats{}
if sq.conf.AcceptCdr(cdr) != true {
t.Error("Should have accepted thif CDR: %+v", cdr)
t.Errorf("Should have accepted thif CDR: %+v", cdr)
}
sq.conf = &CdrStats{TOR: []string{"test"}}
if sq.conf.AcceptCdr(cdr) == true {
t.Error("Should have NOT accepted thif CDR: %+v", cdr)
t.Errorf("Should have NOT accepted thif CDR: %+v", cdr)
}
sq.conf = &CdrStats{CdrHost: []string{"test"}}
if sq.conf.AcceptCdr(cdr) == true {
t.Error("Should have NOT accepted thif CDR: %+v", cdr)
t.Errorf("Should have NOT accepted thif CDR: %+v", cdr)
}
sq.conf = &CdrStats{CdrSource: []string{"test"}}
if sq.conf.AcceptCdr(cdr) == true {
t.Error("Should have NOT accepted thif CDR: %+v", cdr)
t.Errorf("Should have NOT accepted thif CDR: %+v", cdr)
}
sq.conf = &CdrStats{Direction: []string{"test"}}
if sq.conf.AcceptCdr(cdr) == true {
t.Error("Should have NOT accepted thif CDR: %+v", cdr)
t.Errorf("Should have NOT accepted thif CDR: %+v", cdr)
}
sq.conf = &CdrStats{Tenant: []string{"test"}}
if sq.conf.AcceptCdr(cdr) == true {
t.Error("Should have NOT accepted thif CDR: %+v", cdr)
t.Errorf("Should have NOT accepted thif CDR: %+v", cdr)
}
sq.conf = &CdrStats{Category: []string{"test"}}
if sq.conf.AcceptCdr(cdr) == true {
t.Error("Should have NOT accepted thif CDR: %+v", cdr)
t.Errorf("Should have NOT accepted thif CDR: %+v", cdr)
}
sq.conf = &CdrStats{Account: []string{"test"}}
if sq.conf.AcceptCdr(cdr) == true {
t.Error("Should have NOT accepted thif CDR: %+v", cdr)
t.Errorf("Should have NOT accepted thif CDR: %+v", cdr)
}
sq.conf = &CdrStats{Subject: []string{"test"}}
if sq.conf.AcceptCdr(cdr) == true {
t.Error("Should have NOT accepted thif CDR: %+v", cdr)
t.Errorf("Should have NOT accepted thif CDR: %+v", cdr)
}
sq.conf = &CdrStats{RatedAccount: []string{"test"}}
if sq.conf.AcceptCdr(cdr) == true {
t.Error("Should have NOT accepted thif CDR: %+v", cdr)
t.Errorf("Should have NOT accepted thif CDR: %+v", cdr)
}
sq.conf = &CdrStats{RatedSubject: []string{"test"}}
if sq.conf.AcceptCdr(cdr) == true {
t.Error("Should have NOT accepted thif CDR: %+v", cdr)
t.Errorf("Should have NOT accepted thif CDR: %+v", cdr)
}
sq.conf = &CdrStats{DestinationPrefix: []string{"test"}}
if sq.conf.AcceptCdr(cdr) == true {
t.Error("Should have NOT accepted thif CDR: %+v", cdr)
t.Errorf("Should have NOT accepted thif CDR: %+v", cdr)
}
sq.conf = &CdrStats{DestinationPrefix: []string{"test", "123"}}
if sq.conf.AcceptCdr(cdr) != true {
t.Error("Should have accepted thif CDR: %+v", cdr)
t.Errorf("Should have accepted thif CDR: %+v", cdr)
}
sq.conf = &CdrStats{SetupInterval: []time.Time{time.Date(2014, 7, 3, 13, 43, 0, 1, time.UTC)}}
if sq.conf.AcceptCdr(cdr) == true {
t.Error("Should have NOT accepted thif CDR: %+v", cdr)
t.Errorf("Should have NOT accepted thif CDR: %+v", cdr)
}
sq.conf = &CdrStats{SetupInterval: []time.Time{time.Date(2014, 7, 3, 13, 42, 0, 0, time.UTC), time.Date(2014, 7, 3, 13, 43, 0, 0, time.UTC)}}
if sq.conf.AcceptCdr(cdr) == true {
t.Error("Should have NOT accepted thif CDR: %+v", cdr)
t.Errorf("Should have NOT accepted thif CDR: %+v", cdr)
}
sq.conf = &CdrStats{SetupInterval: []time.Time{time.Date(2014, 7, 3, 13, 42, 0, 0, time.UTC)}}
if sq.conf.AcceptCdr(cdr) != true {
t.Error("Should have accepted thif CDR: %+v", cdr)
t.Errorf("Should have accepted thif CDR: %+v", cdr)
}
sq.conf = &CdrStats{SetupInterval: []time.Time{time.Date(2014, 7, 3, 13, 42, 0, 0, time.UTC), time.Date(2014, 7, 3, 13, 43, 0, 1, time.UTC)}}
if sq.conf.AcceptCdr(cdr) != true {
t.Error("Should have accepted thif CDR: %+v", cdr)
t.Errorf("Should have accepted thif CDR: %+v", cdr)
}
sq.conf = &CdrStats{UsageInterval: []time.Duration{11 * time.Second}}
if sq.conf.AcceptCdr(cdr) == true {
t.Error("Should have NOT accepted thif CDR: %+v", cdr)
t.Errorf("Should have NOT accepted thif CDR: %+v", cdr)
}
sq.conf = &CdrStats{UsageInterval: []time.Duration{1 * time.Second, 10 * time.Second}}
if sq.conf.AcceptCdr(cdr) == true {
t.Error("Should have NOT accepted thif CDR: %+v", cdr)
t.Errorf("Should have NOT accepted thif CDR: %+v", cdr)
}
sq.conf = &CdrStats{UsageInterval: []time.Duration{10 * time.Second, 11 * time.Second}}
if sq.conf.AcceptCdr(cdr) != true {
t.Error("Should have accepted thif CDR: %+v", cdr)
t.Errorf("Should have accepted thif CDR: %+v", cdr)
}
}
@@ -185,12 +185,12 @@ func TestStatsQueueIds(t *testing.T) {
cdrStats := NewStats(dataStorage)
ids := []string{}
if err := cdrStats.GetQueueIds(0, &ids); err != nil {
t.Error("Error getting queue ids: ", err)
t.Error("Errorf getting queue ids: ", err)
}
result := len(ids)
expected := 2
if result != expected {
t.Errorf("Error loading stats queues. Expected %v was %v", expected, result)
t.Errorf("Errorf loading stats queues. Expected %v was %v", expected, result)
}
}

View File

@@ -77,7 +77,7 @@ func TestMySQLSetGetTPTiming(t *testing.T) {
if tmgs, err := mysqlDb.GetTpTimings(TEST_SQL, tm.TimingId); err != nil {
t.Error(err.Error())
} else if !reflect.DeepEqual(tm, tmgs[tm.TimingId]) {
t.Errorf("Expecting: %+v, received: %+v", tmgs[tm.TimingId])
t.Errorf("Expecting: %+v, received: %+v", tm, tmgs[tm.TimingId])
}
}

View File

@@ -67,7 +67,7 @@ func TestPSQLSetGetTPTiming(t *testing.T) {
if tmgs, err := psqlDb.GetTpTimings(TEST_SQL, tm.TimingId); err != nil {
t.Error(err.Error())
} else if !reflect.DeepEqual(tm, tmgs[tm.TimingId]) {
t.Errorf("Expecting: %+v, received: %+v", tmgs[tm.TimingId])
t.Errorf("Expecting: %+v, received: %+v", tm, tmgs[tm.TimingId])
}
// Update
tm.Time = "00:00:01"
@@ -77,7 +77,7 @@ func TestPSQLSetGetTPTiming(t *testing.T) {
if tmgs, err := psqlDb.GetTpTimings(TEST_SQL, tm.TimingId); err != nil {
t.Error(err.Error())
} else if !reflect.DeepEqual(tm, tmgs[tm.TimingId]) {
t.Errorf("Expecting: %+v, received: %+v", tmgs[tm.TimingId])
t.Errorf("Expecting: %+v, received: %+v", tm, tmgs[tm.TimingId])
}
}

View File

@@ -87,7 +87,7 @@ func (rs *RedisStorage) CacheRating(dKeys, rpKeys, rpfKeys, alsKeys, lcrKeys []s
}
for _, key := range dKeys {
if len(key) <= len(DESTINATION_PREFIX) {
Logger.Warning(fmt.Sprintf("Got malformed destination id: ", key))
Logger.Warning(fmt.Sprintf("Got malformed destination id: %s", key))
continue
}
if _, err = rs.GetDestination(key[len(DESTINATION_PREFIX):]); err != nil {

View File

@@ -478,7 +478,7 @@ func (self *SQLStorage) SetTPLCRs(tpid string, lcrs map[string]*LCR) error {
if i != 0 { //Consecutive values after the first will be prefixed with "," as separator
buffer.WriteRune(',')
}
buffer.WriteString(fmt.Sprintf("('%s','%s','%s','%s','%s','%s','%s','%v','%v')",
buffer.WriteString(fmt.Sprintf("('%s','%s','%s','%s','%s','%s','%s','%v','%v', '%v')",
tpid, lcr.Direction, lcr.Tenant, lcr.Customer, entry.DestinationId, entry.Category, entry.Strategy, entry.Suppliers, act.ActivationTime, entry.Weight))
i++
}