make the VoucherMetadata more descriptive
This commit is contained in:
@@ -9,12 +9,12 @@ import (
|
||||
dataserviceapi "github.com/grassrootseconomics/ussd-data-service/pkg/api"
|
||||
)
|
||||
|
||||
// VoucherMetadata helps organize voucher data fields
|
||||
// VoucherMetadata helps organize data fields
|
||||
type VoucherMetadata struct {
|
||||
Symbol string
|
||||
Balance string
|
||||
Decimal string
|
||||
Address string
|
||||
Symbols string
|
||||
Balances string
|
||||
Decimals string
|
||||
Addresses string
|
||||
}
|
||||
|
||||
// ProcessVouchers converts holdings into formatted strings
|
||||
@@ -29,10 +29,10 @@ func ProcessVouchers(holdings []dataserviceapi.TokenHoldings) VoucherMetadata {
|
||||
addresses = append(addresses, fmt.Sprintf("%d:%s", i+1, h.ContractAddress))
|
||||
}
|
||||
|
||||
data.Symbol = strings.Join(symbols, "\n")
|
||||
data.Balance = strings.Join(balances, "\n")
|
||||
data.Decimal = strings.Join(decimals, "\n")
|
||||
data.Address = strings.Join(addresses, "\n")
|
||||
data.Symbols = strings.Join(symbols, "\n")
|
||||
data.Balances = strings.Join(balances, "\n")
|
||||
data.Decimals = strings.Join(decimals, "\n")
|
||||
data.Addresses = strings.Join(addresses, "\n")
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
@@ -68,10 +68,10 @@ func TestProcessVouchers(t *testing.T) {
|
||||
}
|
||||
|
||||
expectedResult := VoucherMetadata{
|
||||
Symbol: "1:SRF\n2:MILO",
|
||||
Balance: "1:100\n2:200",
|
||||
Decimal: "1:6\n2:4",
|
||||
Address: "1:0xd4c288865Ce\n2:0x41c188d63Qa",
|
||||
Symbols: "1:SRF\n2:MILO",
|
||||
Balances: "1:100\n2:200",
|
||||
Decimals: "1:6\n2:4",
|
||||
Addresses: "1:0xd4c288865Ce\n2:0x41c188d63Qa",
|
||||
}
|
||||
|
||||
result := ProcessVouchers(holdings)
|
||||
|
||||
Reference in New Issue
Block a user