More test in utils/apidata_test.go

This commit is contained in:
andronache
2020-11-25 16:28:34 +02:00
committed by Dan Christian Bogos
parent 9a86ffd40b
commit 3af438ac06

View File

@@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
package utils
import (
"fmt"
"reflect"
"strings"
"testing"
@@ -1115,3 +1116,39 @@ func TestStartTimeError(t *testing.T) {
t.Errorf("Expected <nil> , received <%+v>", err)
}
}
func TestUsageMinute(t *testing.T) {
testCostEventStruct := &ArgsCostForEvent{
RateProfileIDs: []string{"123", "456", "789"},
CGREventWithOpts: &CGREventWithOpts{
Opts: map[string]interface{}{},
CGREvent: &CGREvent{
Tenant: "*req.CGRID",
ID: "",
Event: map[string]interface{}{},
},
},
}
if result, err := testCostEventStruct.Usage(); err != nil {
t.Errorf("Expected <nil> , received <%+v>", err)
} else if !reflect.DeepEqual(result, time.Minute) {
t.Errorf("Expected <%+v> , received <%+v>", time.Minute, result)
}
}
func TestUsage(t *testing.T) {
testCostEventStruct := &ArgsCostForEvent{
RateProfileIDs: []string{"123", "456", "789"},
CGREventWithOpts: &CGREventWithOpts{
Opts: map[string]interface{}{"*ratesStartTime": "start"},
CGREvent: &CGREvent{
Tenant: "*req.CGRID",
ID: "",
Event: map[string]interface{}{},
},
},
}
result, err := testCostEventStruct.Usage()
fmt.Println(result)
fmt.Println(err)
}