[#90] proto/test: Fix go vet warnings

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2024-07-12 17:45:29 +03:00
parent 141c4cb3ef
commit dee4325075

View file

@ -441,7 +441,7 @@ func TestFixed32Marshal(t *testing.T) {
}) })
} }
func testMarshal(t *testing.T, c stablePrimitives, tr test.Primitives, wrongField bool) *test.Primitives { func testMarshal(t *testing.T, c stablePrimitives, tr *test.Primitives, wrongField bool) *test.Primitives {
var ( var (
wire []byte wire []byte
err error err error
@ -449,7 +449,7 @@ func testMarshal(t *testing.T, c stablePrimitives, tr test.Primitives, wrongFiel
wire, err = c.stableMarshal(nil, wrongField) wire, err = c.stableMarshal(nil, wrongField)
require.NoError(t, err) require.NoError(t, err)
wireGen, err := goproto.Marshal(&tr) wireGen, err := goproto.Marshal(tr)
require.NoError(t, err) require.NoError(t, err)
if !wrongField { if !wrongField {
@ -472,7 +472,7 @@ func testBytesMarshal(t *testing.T, data []byte, wrongField bool) {
transport = test.Primitives{FieldA: data} transport = test.Primitives{FieldA: data}
) )
result := testMarshal(t, custom, transport, wrongField) result := testMarshal(t, custom, &transport, wrongField)
if !wrongField { if !wrongField {
require.Len(t, result.FieldA, len(data)) require.Len(t, result.FieldA, len(data))
@ -490,7 +490,7 @@ func testStringMarshal(t *testing.T, s string, wrongField bool) {
transport = test.Primitives{FieldB: s} transport = test.Primitives{FieldB: s}
) )
result := testMarshal(t, custom, transport, wrongField) result := testMarshal(t, custom, &transport, wrongField)
if !wrongField { if !wrongField {
require.Len(t, result.FieldB, len(s)) require.Len(t, result.FieldB, len(s))
@ -508,7 +508,7 @@ func testBoolMarshal(t *testing.T, b bool, wrongField bool) {
transport = test.Primitives{FieldC: b} transport = test.Primitives{FieldC: b}
) )
result := testMarshal(t, custom, transport, wrongField) result := testMarshal(t, custom, &transport, wrongField)
if !wrongField { if !wrongField {
require.Equal(t, b, result.FieldC) require.Equal(t, b, result.FieldC)
@ -523,7 +523,7 @@ func testInt32Marshal(t *testing.T, n int32, wrongField bool) {
transport = test.Primitives{FieldD: n} transport = test.Primitives{FieldD: n}
) )
result := testMarshal(t, custom, transport, wrongField) result := testMarshal(t, custom, &transport, wrongField)
if !wrongField { if !wrongField {
require.Equal(t, n, result.FieldD) require.Equal(t, n, result.FieldD)
@ -538,7 +538,7 @@ func testUInt32Marshal(t *testing.T, n uint32, wrongField bool) {
transport = test.Primitives{FieldE: n} transport = test.Primitives{FieldE: n}
) )
result := testMarshal(t, custom, transport, wrongField) result := testMarshal(t, custom, &transport, wrongField)
if !wrongField { if !wrongField {
require.Equal(t, n, result.FieldE) require.Equal(t, n, result.FieldE)
@ -553,7 +553,7 @@ func testInt64Marshal(t *testing.T, n int64, wrongField bool) {
transport = test.Primitives{FieldF: n} transport = test.Primitives{FieldF: n}
) )
result := testMarshal(t, custom, transport, wrongField) result := testMarshal(t, custom, &transport, wrongField)
if !wrongField { if !wrongField {
require.Equal(t, n, result.FieldF) require.Equal(t, n, result.FieldF)
@ -568,7 +568,7 @@ func testUInt64Marshal(t *testing.T, n uint64, wrongField bool) {
transport = test.Primitives{FieldG: n} transport = test.Primitives{FieldG: n}
) )
result := testMarshal(t, custom, transport, wrongField) result := testMarshal(t, custom, &transport, wrongField)
if !wrongField { if !wrongField {
require.Equal(t, n, result.FieldG) require.Equal(t, n, result.FieldG)
@ -583,7 +583,7 @@ func testFloat64Marshal(t *testing.T, n float64, wrongField bool) {
transport = test.Primitives{FieldJ: n} transport = test.Primitives{FieldJ: n}
) )
result := testMarshal(t, custom, transport, wrongField) result := testMarshal(t, custom, &transport, wrongField)
if !wrongField { if !wrongField {
require.Equal(t, n, result.FieldJ) require.Equal(t, n, result.FieldJ)
@ -598,7 +598,7 @@ func testEnumMarshal(t *testing.T, e SomeEnum, wrongField bool) {
transport = test.Primitives{FieldH: test.Primitives_SomeEnum(e)} transport = test.Primitives{FieldH: test.Primitives_SomeEnum(e)}
) )
result := testMarshal(t, custom, transport, wrongField) result := testMarshal(t, custom, &transport, wrongField)
if !wrongField { if !wrongField {
require.EqualValues(t, custom.FieldH, result.FieldH) require.EqualValues(t, custom.FieldH, result.FieldH)
@ -607,7 +607,7 @@ func testEnumMarshal(t *testing.T, e SomeEnum, wrongField bool) {
} }
} }
func testRepMarshal(t *testing.T, c stableRepPrimitives, tr test.RepPrimitives, wrongField bool) *test.RepPrimitives { func testRepMarshal(t *testing.T, c stableRepPrimitives, tr *test.RepPrimitives, wrongField bool) *test.RepPrimitives {
var ( var (
wire []byte wire []byte
err error err error
@ -615,7 +615,7 @@ func testRepMarshal(t *testing.T, c stableRepPrimitives, tr test.RepPrimitives,
wire, err = c.stableMarshal(nil, wrongField) wire, err = c.stableMarshal(nil, wrongField)
require.NoError(t, err) require.NoError(t, err)
wireGen, err := goproto.Marshal(&tr) wireGen, err := goproto.Marshal(tr)
require.NoError(t, err) require.NoError(t, err)
if !wrongField { if !wrongField {
@ -638,7 +638,7 @@ func testRepeatedBytesMarshal(t *testing.T, data [][]byte, wrongField bool) {
transport = test.RepPrimitives{FieldA: data} transport = test.RepPrimitives{FieldA: data}
) )
result := testRepMarshal(t, custom, transport, wrongField) result := testRepMarshal(t, custom, &transport, wrongField)
if !wrongField { if !wrongField {
require.Len(t, result.FieldA, len(data)) require.Len(t, result.FieldA, len(data))
@ -656,7 +656,7 @@ func testRepeatedStringMarshal(t *testing.T, s []string, wrongField bool) {
transport = test.RepPrimitives{FieldB: s} transport = test.RepPrimitives{FieldB: s}
) )
result := testRepMarshal(t, custom, transport, wrongField) result := testRepMarshal(t, custom, &transport, wrongField)
if !wrongField { if !wrongField {
require.Len(t, result.FieldB, len(s)) require.Len(t, result.FieldB, len(s))
@ -674,7 +674,7 @@ func testRepeatedInt32Marshal(t *testing.T, n []int32, wrongField bool) {
transport = test.RepPrimitives{FieldC: n} transport = test.RepPrimitives{FieldC: n}
) )
result := testRepMarshal(t, custom, transport, wrongField) result := testRepMarshal(t, custom, &transport, wrongField)
if !wrongField { if !wrongField {
require.Len(t, result.FieldC, len(n)) require.Len(t, result.FieldC, len(n))
@ -692,7 +692,7 @@ func testRepeatedUInt32Marshal(t *testing.T, n []uint32, wrongField bool) {
transport = test.RepPrimitives{FieldD: n} transport = test.RepPrimitives{FieldD: n}
) )
result := testRepMarshal(t, custom, transport, wrongField) result := testRepMarshal(t, custom, &transport, wrongField)
if !wrongField { if !wrongField {
require.Len(t, result.FieldD, len(n)) require.Len(t, result.FieldD, len(n))
@ -710,7 +710,7 @@ func testRepeatedInt64Marshal(t *testing.T, n []int64, wrongField bool) {
transport = test.RepPrimitives{FieldE: n} transport = test.RepPrimitives{FieldE: n}
) )
result := testRepMarshal(t, custom, transport, wrongField) result := testRepMarshal(t, custom, &transport, wrongField)
if !wrongField { if !wrongField {
require.Len(t, result.FieldE, len(n)) require.Len(t, result.FieldE, len(n))
@ -728,7 +728,7 @@ func testRepeatedUInt64Marshal(t *testing.T, n []uint64, wrongField bool) {
transport = test.RepPrimitives{FieldF: n} transport = test.RepPrimitives{FieldF: n}
) )
result := testRepMarshal(t, custom, transport, wrongField) result := testRepMarshal(t, custom, &transport, wrongField)
if !wrongField { if !wrongField {
require.Len(t, result.FieldF, len(n)) require.Len(t, result.FieldF, len(n))
@ -746,7 +746,7 @@ func testFixed64Marshal(t *testing.T, n uint64, wrongField bool) {
transport = test.Primitives{FieldI: n} transport = test.Primitives{FieldI: n}
) )
result := testMarshal(t, custom, transport, wrongField) result := testMarshal(t, custom, &transport, wrongField)
if !wrongField { if !wrongField {
require.Equal(t, n, result.FieldI) require.Equal(t, n, result.FieldI)
@ -761,7 +761,7 @@ func testFixed32Marshal(t *testing.T, n uint32, wrongField bool) {
transport = test.Primitives{FieldK: n} transport = test.Primitives{FieldK: n}
) )
result := testMarshal(t, custom, transport, wrongField) result := testMarshal(t, custom, &transport, wrongField)
if !wrongField { if !wrongField {
require.Equal(t, n, result.FieldK) require.Equal(t, n, result.FieldK)