frostfs-sdk-go/api/accounting/test/generate.go
Pavel Pogodaev 6ce73790ea
All checks were successful
DCO / DCO (pull_request) Successful in 38s
Tests and linters / Tests (pull_request) Successful in 1m13s
Tests and linters / Lint (pull_request) Successful in 2m36s
[#276] Merge repo with frostfs-api-go
Signed-off-by: Pavel Pogodaev <p.pogodaev@yadro.com>
2024-10-22 14:05:12 +00:00

64 lines
1.4 KiB
Go

package accountingtest
import (
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/accounting"
accountingtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/refs/test"
sessiontest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/session/test"
)
func GenerateBalanceRequest(empty bool) *accounting.BalanceRequest {
m := new(accounting.BalanceRequest)
if !empty {
m.SetBody(GenerateBalanceRequestBody(false))
}
m.SetMetaHeader(sessiontest.GenerateRequestMetaHeader(empty))
m.SetVerificationHeader(sessiontest.GenerateRequestVerificationHeader(empty))
return m
}
func GenerateBalanceRequestBody(empty bool) *accounting.BalanceRequestBody {
m := new(accounting.BalanceRequestBody)
if !empty {
m.SetOwnerID(accountingtest.GenerateOwnerID(false))
}
return m
}
func GenerateBalanceResponse(empty bool) *accounting.BalanceResponse {
m := new(accounting.BalanceResponse)
if !empty {
m.SetBody(GenerateBalanceResponseBody(false))
}
m.SetMetaHeader(sessiontest.GenerateResponseMetaHeader(empty))
m.SetVerificationHeader(sessiontest.GenerateResponseVerificationHeader(empty))
return m
}
func GenerateBalanceResponseBody(empty bool) *accounting.BalanceResponseBody {
m := new(accounting.BalanceResponseBody)
if !empty {
m.SetBalance(GenerateDecimal(false))
}
return m
}
func GenerateDecimal(empty bool) *accounting.Decimal {
m := new(accounting.Decimal)
if !empty {
m.SetValue(1)
m.SetPrecision(2)
}
return m
}