forked from TrueCloudLab/frostfs-api-go
[#307] v2/accounting/test: Do not allocate memory if !empty
Move all memory allocation and field settings in `Generate...(empty bool)` functions behind `if !empty` check. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
176be8ead1
commit
51f20a76c5
1 changed files with 14 additions and 4 deletions
|
@ -9,7 +9,10 @@ import (
|
||||||
func GenerateBalanceRequest(empty bool) *accounting.BalanceRequest {
|
func GenerateBalanceRequest(empty bool) *accounting.BalanceRequest {
|
||||||
m := new(accounting.BalanceRequest)
|
m := new(accounting.BalanceRequest)
|
||||||
|
|
||||||
m.SetBody(GenerateBalanceRequestBody(empty))
|
if !empty {
|
||||||
|
m.SetBody(GenerateBalanceRequestBody(false))
|
||||||
|
}
|
||||||
|
|
||||||
m.SetMetaHeader(sessiontest.GenerateRequestMetaHeader(empty))
|
m.SetMetaHeader(sessiontest.GenerateRequestMetaHeader(empty))
|
||||||
m.SetVerificationHeader(sessiontest.GenerateRequestVerificationHeader(empty))
|
m.SetVerificationHeader(sessiontest.GenerateRequestVerificationHeader(empty))
|
||||||
|
|
||||||
|
@ -19,7 +22,9 @@ func GenerateBalanceRequest(empty bool) *accounting.BalanceRequest {
|
||||||
func GenerateBalanceRequestBody(empty bool) *accounting.BalanceRequestBody {
|
func GenerateBalanceRequestBody(empty bool) *accounting.BalanceRequestBody {
|
||||||
m := new(accounting.BalanceRequestBody)
|
m := new(accounting.BalanceRequestBody)
|
||||||
|
|
||||||
m.SetOwnerID(accountingtest.GenerateOwnerID(empty))
|
if !empty {
|
||||||
|
m.SetOwnerID(accountingtest.GenerateOwnerID(false))
|
||||||
|
}
|
||||||
|
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
@ -27,7 +32,10 @@ func GenerateBalanceRequestBody(empty bool) *accounting.BalanceRequestBody {
|
||||||
func GenerateBalanceResponse(empty bool) *accounting.BalanceResponse {
|
func GenerateBalanceResponse(empty bool) *accounting.BalanceResponse {
|
||||||
m := new(accounting.BalanceResponse)
|
m := new(accounting.BalanceResponse)
|
||||||
|
|
||||||
m.SetBody(GenerateBalanceResponseBody(empty))
|
if !empty {
|
||||||
|
m.SetBody(GenerateBalanceResponseBody(false))
|
||||||
|
}
|
||||||
|
|
||||||
m.SetMetaHeader(sessiontest.GenerateResponseMetaHeader(empty))
|
m.SetMetaHeader(sessiontest.GenerateResponseMetaHeader(empty))
|
||||||
m.SetVerificationHeader(sessiontest.GenerateResponseVerificationHeader(empty))
|
m.SetVerificationHeader(sessiontest.GenerateResponseVerificationHeader(empty))
|
||||||
|
|
||||||
|
@ -37,7 +45,9 @@ func GenerateBalanceResponse(empty bool) *accounting.BalanceResponse {
|
||||||
func GenerateBalanceResponseBody(empty bool) *accounting.BalanceResponseBody {
|
func GenerateBalanceResponseBody(empty bool) *accounting.BalanceResponseBody {
|
||||||
m := new(accounting.BalanceResponseBody)
|
m := new(accounting.BalanceResponseBody)
|
||||||
|
|
||||||
m.SetBalance(GenerateDecimal(empty))
|
if !empty {
|
||||||
|
m.SetBalance(GenerateDecimal(false))
|
||||||
|
}
|
||||||
|
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue