Skip to content

Commit d667fd2

Browse files
fix(bcdc): linting
1 parent 5e7d918 commit d667fd2

File tree

1 file changed

+68
-68
lines changed

1 file changed

+68
-68
lines changed

binary-codec/types/amount_test.go

Lines changed: 68 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,39 +1118,39 @@ func TestAmount_ToJson(t *testing.T) {
11181118

11191119
// TestValueToString covers all branches of valueToString
11201120
func TestValueToString(t *testing.T) {
1121-
tests := []struct {
1122-
name string
1123-
input any
1124-
exp string
1125-
expErr bool
1126-
}{
1127-
{"pass - string", "foo", "foo", false},
1128-
{"pass - json.Number", json.Number("123.45"), "123.45", false},
1129-
{"pass - float64 integer", float64(42), "42", false},
1130-
{"pass - float64 decimal", float64(3.14), "3.14", false},
1131-
{"pass - float64 negative", float64(-2.5), "-2.5", false},
1132-
{"pass - float64 zero", float64(0), "0", false},
1133-
{"pass - float64 large integer", float64(1000000), "1000000", false},
1134-
{"fail - unsupported int", int(7), "", true},
1135-
{"fail - unsupported int64", int64(8), "", true},
1136-
{"fail - unsupported uint64", uint64(9), "", true},
1137-
{"fail - unsupported slice", []int{1, 2, 3}, "", true},
1138-
{"fail - unsupported map", map[string]string{"key": "value"}, "", true},
1139-
{"fail - unsupported nil", nil, "", true},
1140-
}
1121+
tests := []struct {
1122+
name string
1123+
input any
1124+
exp string
1125+
expErr bool
1126+
}{
1127+
{"pass - string", "foo", "foo", false},
1128+
{"pass - json.Number", json.Number("123.45"), "123.45", false},
1129+
{"pass - float64 integer", float64(42), "42", false},
1130+
{"pass - float64 decimal", float64(3.14), "3.14", false},
1131+
{"pass - float64 negative", float64(-2.5), "-2.5", false},
1132+
{"pass - float64 zero", float64(0), "0", false},
1133+
{"pass - float64 large integer", float64(1000000), "1000000", false},
1134+
{"fail - unsupported int", int(7), "", true},
1135+
{"fail - unsupported int64", int64(8), "", true},
1136+
{"fail - unsupported uint64", uint64(9), "", true},
1137+
{"fail - unsupported slice", []int{1, 2, 3}, "", true},
1138+
{"fail - unsupported map", map[string]string{"key": "value"}, "", true},
1139+
{"fail - unsupported nil", nil, "", true},
1140+
}
11411141

1142-
for _, tc := range tests {
1143-
t.Run(tc.name, func(t *testing.T) {
1144-
got, err := valueToString(tc.input)
1145-
if tc.expErr {
1146-
require.Error(t, err)
1147-
require.Contains(t, err.Error(), "unsupported type")
1148-
} else {
1149-
require.NoError(t, err)
1150-
require.Equal(t, tc.exp, got)
1151-
}
1152-
})
1153-
}
1142+
for _, tc := range tests {
1143+
t.Run(tc.name, func(t *testing.T) {
1144+
got, err := valueToString(tc.input)
1145+
if tc.expErr {
1146+
require.Error(t, err)
1147+
require.Contains(t, err.Error(), "unsupported type")
1148+
} else {
1149+
require.NoError(t, err)
1150+
require.Equal(t, tc.exp, got)
1151+
}
1152+
})
1153+
}
11541154
}
11551155

11561156
// Extend TestAmount_FromJson with missing‐field and unsupported‐type cases
@@ -1163,42 +1163,42 @@ func TestAmount_FromJson_Errors(t *testing.T) {
11631163
input any
11641164
expErr string
11651165
}{
1166-
{
1167-
name: "fail - missing value",
1168-
input: map[string]any{"currency": currency, "issuer": issuer},
1169-
expErr: "amount missing value field",
1170-
},
1171-
{
1172-
name: "fail - unsupported value type",
1173-
input: map[string]any{"value": []int{1}, "currency": currency, "issuer": issuer},
1174-
expErr: "invalid amount value: unsupported type \\[\\]int for amount value",
1175-
},
1176-
{
1177-
name: "fail - missing currency",
1178-
input: map[string]any{"value": "1", "issuer": issuer},
1179-
expErr: "issued currency missing currency field",
1180-
},
1181-
{
1182-
name: "fail - missing issuer (IOU)",
1183-
input: map[string]any{"value": "1", "currency": currency},
1184-
expErr: "issued currency missing issuer field",
1185-
},
1186-
{
1187-
name: "fail - unsupported mpt_issuance_id type",
1188-
input: map[string]any{"value": "1", "mpt_issuance_id": []int{1}},
1189-
expErr: "invalid mpt_issuance_id: unsupported type \\[\\]int for amount value",
1190-
},
1191-
{
1192-
name: "fail - invalid mpt_issuance_id hex",
1193-
input: map[string]any{"value": "1", "mpt_issuance_id": "zzzz"},
1194-
expErr: "encoding/hex: invalid byte",
1195-
},
1196-
{
1197-
name: "fail - invalid amount type",
1198-
input: 123,
1199-
expErr: "invalid amount type",
1200-
},
1201-
}
1166+
{
1167+
name: "fail - missing value",
1168+
input: map[string]any{"currency": currency, "issuer": issuer},
1169+
expErr: "amount missing value field",
1170+
},
1171+
{
1172+
name: "fail - unsupported value type",
1173+
input: map[string]any{"value": []int{1}, "currency": currency, "issuer": issuer},
1174+
expErr: "invalid amount value: unsupported type \\[\\]int for amount value",
1175+
},
1176+
{
1177+
name: "fail - missing currency",
1178+
input: map[string]any{"value": "1", "issuer": issuer},
1179+
expErr: "issued currency missing currency field",
1180+
},
1181+
{
1182+
name: "fail - missing issuer (IOU)",
1183+
input: map[string]any{"value": "1", "currency": currency},
1184+
expErr: "issued currency missing issuer field",
1185+
},
1186+
{
1187+
name: "fail - unsupported mpt_issuance_id type",
1188+
input: map[string]any{"value": "1", "mpt_issuance_id": []int{1}},
1189+
expErr: "invalid mpt_issuance_id: unsupported type \\[\\]int for amount value",
1190+
},
1191+
{
1192+
name: "fail - invalid mpt_issuance_id hex",
1193+
input: map[string]any{"value": "1", "mpt_issuance_id": "zzzz"},
1194+
expErr: "encoding/hex: invalid byte",
1195+
},
1196+
{
1197+
name: "fail - invalid amount type",
1198+
input: 123,
1199+
expErr: "invalid amount type",
1200+
},
1201+
}
12021202

12031203
for _, tc := range cases {
12041204
t.Run(tc.name, func(t *testing.T) {

0 commit comments

Comments
 (0)