Cover the remainder of engine/destinations.go

This commit is contained in:
ionutboangiu
2021-04-09 15:43:05 +03:00
committed by Dan Christian Bogos
parent 65bf6eeb2c
commit 7a71b07223
2 changed files with 30 additions and 3 deletions

View File

@@ -126,6 +126,28 @@ func TestDestinationNonCachedDestWrongPrefix(t *testing.T) {
}
}
func TestDestinationcontainsPrefixNilDestination(t *testing.T) {
var d *Destination
rcv := d.containsPrefix("prefix")
if rcv != 0 {
t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", 0, rcv)
}
}
func TestDestinationString(t *testing.T) {
d := &Destination{
Id: "ID",
Prefixes: []string{"prefix1", "prefix2", "prefix3"},
}
exp := "ID: prefix1, prefix2, prefix3"
rcv := d.String()
if rcv != exp {
t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", exp, rcv)
}
}
/********************************* Benchmarks **********************************/
func BenchmarkDestinationStorageStoreRestore(b *testing.B) {

View File

@@ -302,10 +302,15 @@ func TestVersionCheckVersionsCompareNonNilMsg(t *testing.T) {
testcase: "Compare returns non-nil message",
}
experr := fmt.Sprintf("Migration needed: please backup cgr data and run : <%s>", "cgr-migrator -exec=*cost_details")
experr1 := fmt.Sprintf("Migration needed: please backup cgr data and run : <%s>", "cgr-migrator -exec=*cost_details")
experr2 := fmt.Sprintf("Migration needed: please backup cgr data and run : <%s>", "cgr-migrator -exec=*sessions_costs")
err := CheckVersions(storage)
if err == nil || err.Error() != experr {
t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", experr, err)
if err == nil || (err.Error() != experr1 && err.Error() != experr2) {
if err.Error() == experr1 {
t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", experr1, err)
} else {
t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", experr2, err)
}
}
}