mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-12 02:26:26 +05:00
Added ApierV1CountAccounts
This commit is contained in:
@@ -593,3 +593,15 @@ func (api *ApierV1) RemoveBalances(attr *utils.AttrSetBalance, reply *string) (e
|
||||
*reply = utils.OK
|
||||
return nil
|
||||
}
|
||||
|
||||
func (api *ApierV1) CountAccounts(attr utils.TenantArg, reply *int) (err error) {
|
||||
if len(attr.Tenant) == 0 {
|
||||
return utils.NewErrMandatoryIeMissing("Tenant")
|
||||
}
|
||||
var accountKeys []string
|
||||
if accountKeys, err = api.DataManager.DataDB().GetKeysForPrefix(utils.ACCOUNT_PREFIX + attr.Tenant); err != nil {
|
||||
return
|
||||
}
|
||||
*reply = len(accountKeys)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ var (
|
||||
testAccITSetBalanceTimingIds,
|
||||
testAccITAddBalanceWithNegative,
|
||||
testAccITGetDisabledAccounts,
|
||||
testAccITCountAccounts,
|
||||
testAccITStopCgrEngine,
|
||||
}
|
||||
)
|
||||
@@ -481,6 +482,17 @@ func testAccITGetDisabledAccounts(t *testing.T) {
|
||||
t.Errorf("Accounts received: %+v", acnts)
|
||||
}
|
||||
}
|
||||
func testAccITCountAccounts(t *testing.T) {
|
||||
var reply int
|
||||
args := &utils.TenantArg{
|
||||
Tenant: "cgrates.org",
|
||||
}
|
||||
if err := accRPC.Call(utils.ApierV1CountAccounts, args, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if reply != 10 {
|
||||
t.Errorf("Expecting: %v, received: %v", 10, reply)
|
||||
}
|
||||
}
|
||||
|
||||
func testAccITStopCgrEngine(t *testing.T) {
|
||||
if err := engine.KillEngine(100); err != nil {
|
||||
|
||||
@@ -961,6 +961,7 @@ const (
|
||||
ApierV1AddBalance = "ApierV1.AddBalance"
|
||||
ApierV1DebitBalance = "ApierV1.DebitBalance"
|
||||
ApierV1SetAccount = "ApierV1.SetAccount"
|
||||
ApierV1CountAccounts = "ApierV1.CountAccounts"
|
||||
ApierV1GetDataDBVersions = "ApierV1.GetDataDBVersions"
|
||||
ApierV1GetStorDBVersions = "ApierV1.GetStorDBVersions"
|
||||
ApierV1GetCDRs = "ApierV1.GetCDRs"
|
||||
|
||||
Reference in New Issue
Block a user