From 9e0e3ed4687af873dc5658b705ecd4ed8a617cd2 Mon Sep 17 00:00:00 2001 From: adragusin Date: Mon, 6 Jan 2020 15:24:11 +0200 Subject: [PATCH] Added test for Account.GetBalanceWithID --- engine/account_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/engine/account_test.go b/engine/account_test.go index 602a6b745..e3de1b7fb 100644 --- a/engine/account_test.go +++ b/engine/account_test.go @@ -2370,6 +2370,25 @@ func TestAccountClone(t *testing.T) { } +func TestAccountGetBalanceWithID(t *testing.T){ + account := &Account{ + BalanceMap: map[string]Balances{ + "type1" : Balances{&Balance{ID: "test1",Value: 0.7,}}, + "type2" :Balances{&Balance{ID: "test2",Value: 0.8,}}, + }, + } + if rcv := account.GetBalanceWithID("type1","test1"); rcv.Value != 0.7{ + t.Errorf("Expecting: 0.7, received: %+v",rcv) + } + if rcv := account.GetBalanceWithID("type2","test2"); rcv.Value != 0.8{ + t.Errorf("Expecting: 0.8, received: %+v",rcv) + } + if rcv := account.GetBalanceWithID("unknown","unknown"); rcv != nil{ + t.Errorf("Expecting: nil, received: %+v",rcv) + } +} + + /*********************************** Benchmarks *******************************/ func BenchmarkGetSecondForPrefix(b *testing.B) {