diff --git a/binary_test.go b/binary_test.go index 9464562..b1152df 100644 --- a/binary_test.go +++ b/binary_test.go @@ -46,6 +46,7 @@ func init() { } func testBinaryDecodeFail(t *testing.T, schema string, buf []byte, errorMessage string) { + t.Helper() c, err := NewCodec(schema) if err != nil { t.Fatal(err) @@ -61,6 +62,7 @@ func testBinaryDecodeFail(t *testing.T, schema string, buf []byte, errorMessage } func testBinaryEncodeFail(t *testing.T, schema string, datum interface{}, errorMessage string) { + t.Helper() c, err := NewCodec(schema) if err != nil { t.Fatal(err) @@ -73,14 +75,17 @@ func testBinaryEncodeFail(t *testing.T, schema string, datum interface{}, errorM } func testBinaryEncodeFailBadDatumType(t *testing.T, schema string, datum interface{}) { + t.Helper() testBinaryEncodeFail(t, schema, datum, "received: ") } func testBinaryDecodeFailShortBuffer(t *testing.T, schema string, buf []byte) { + t.Helper() testBinaryDecodeFail(t, schema, buf, "short buffer") } func testBinaryDecodePass(t *testing.T, schema string, datum interface{}, encoded []byte) { + t.Helper() codec, err := NewCodec(schema) if err != nil { t.Fatal(err) @@ -105,6 +110,7 @@ func testBinaryDecodePass(t *testing.T, schema string, datum interface{}, encode } func testBinaryEncodePass(t *testing.T, schema string, datum interface{}, expected []byte) { + t.Helper() codec, err := NewCodec(schema) if err != nil { t.Fatalf("Schma: %q %s", schema, err) @@ -122,6 +128,7 @@ func testBinaryEncodePass(t *testing.T, schema string, datum interface{}, expect // testBinaryCodecPass does a bi-directional codec check, by encoding datum to // bytes, then decoding bytes back to datum. func testBinaryCodecPass(t *testing.T, schema string, datum interface{}, buf []byte) { + t.Helper() testBinaryDecodePass(t, schema, datum, buf) testBinaryEncodePass(t, schema, datum, buf) } diff --git a/helperV2_test.go b/helperV2_test.go index f053177..2a84137 100644 --- a/helperV2_test.go +++ b/helperV2_test.go @@ -15,6 +15,7 @@ import ( ) func newCodecUsingV2(tb testing.TB, schema string) *Codec { + tb.Helper() codec, err := NewCodec(schema) if err != nil { tb.Fatal(err) @@ -23,6 +24,7 @@ func newCodecUsingV2(tb testing.TB, schema string) *Codec { } func nativeFromAvroUsingV2(tb testing.TB, avroBlob []byte) ([]interface{}, *Codec) { + tb.Helper() ocf, err := NewOCFReader(bytes.NewReader(avroBlob)) if err != nil { tb.Fatal(err) @@ -43,6 +45,7 @@ func nativeFromAvroUsingV2(tb testing.TB, avroBlob []byte) ([]interface{}, *Code } func binaryFromNativeUsingV2(tb testing.TB, codec *Codec, nativeData []interface{}) [][]byte { + tb.Helper() binaryData := make([][]byte, len(nativeData)) for i, datum := range nativeData { binaryDatum, err := codec.BinaryFromNative(nil, datum) @@ -55,6 +58,7 @@ func binaryFromNativeUsingV2(tb testing.TB, codec *Codec, nativeData []interface } func textFromNativeUsingV2(tb testing.TB, codec *Codec, nativeData []interface{}) [][]byte { + tb.Helper() textData := make([][]byte, len(nativeData)) for i, nativeDatum := range nativeData { textDatum, err := codec.TextualFromNative(nil, nativeDatum) @@ -67,6 +71,7 @@ func textFromNativeUsingV2(tb testing.TB, codec *Codec, nativeData []interface{} } func nativeFromBinaryUsingV2(tb testing.TB, codec *Codec, binaryData [][]byte) []interface{} { + tb.Helper() nativeData := make([]interface{}, len(binaryData)) for i, binaryDatum := range binaryData { nativeDatum, buf, err := codec.NativeFromBinary(binaryDatum) @@ -82,6 +87,7 @@ func nativeFromBinaryUsingV2(tb testing.TB, codec *Codec, binaryData [][]byte) [ } func nativeFromTextUsingV2(tb testing.TB, codec *Codec, textData [][]byte) []interface{} { + tb.Helper() nativeData := make([]interface{}, len(textData)) for i, textDatum := range textData { nativeDatum, buf, err := codec.NativeFromTextual(textDatum) diff --git a/number_recover_test.go b/number_recover_test.go index 232fd6d..b47d2b5 100644 --- a/number_recover_test.go +++ b/number_recover_test.go @@ -15,6 +15,7 @@ import ( ) func testPrimitiveRecoverNative(t *testing.T, schema string, value interface{}) { + t.Helper() codec, err := NewCodec(schema) if err != nil { t.Fatalf("Schema: %s; %s", schema, err) diff --git a/ocf_reader_test.go b/ocf_reader_test.go index 249644f..ced2a56 100644 --- a/ocf_reader_test.go +++ b/ocf_reader_test.go @@ -29,6 +29,7 @@ func TestReadOCFHeaderMagicBytes(t *testing.T) { // func testCannotReadOCFHeader(t *testing.T, input []byte, expected ...string) { + t.Helper() _, err := NewOCFReader(bytes.NewBuffer(append([]byte("Obj\x01"), input...))) ensureError(t, err, append([]string{"cannot read OCF header"}, expected...)...) } diff --git a/ocf_writer_test.go b/ocf_writer_test.go index 1ecb01d..1d334b4 100644 --- a/ocf_writer_test.go +++ b/ocf_writer_test.go @@ -18,6 +18,7 @@ import ( // createTestFile is used to create a new test file fixture with provided data func createTestFile(t *testing.T, pathname string, data []byte) { + t.Helper() nf, err := os.Create(pathname) if err != nil { t.Fatal(err) @@ -90,6 +91,7 @@ func TestNewOCFWriterWhenFileNotEmptyWhenCannotReadOCFHeader(t *testing.T) { } func testNewOCFWriterWhenFile(t *testing.T, pathname string, expected ...string) { + t.Helper() fh, err := os.Open(pathname) if err != nil { t.Fatal(err) diff --git a/text_test.go b/text_test.go index 0183c7d..b4010f4 100644 --- a/text_test.go +++ b/text_test.go @@ -17,6 +17,7 @@ import ( ) func testTextDecodeFail(t *testing.T, schema string, buf []byte, errorMessage string) { + t.Helper() c, err := NewCodec(schema) if err != nil { t.Fatal(err) @@ -32,6 +33,7 @@ func testTextDecodeFail(t *testing.T, schema string, buf []byte, errorMessage st } func testTextEncodeFail(t *testing.T, schema string, datum interface{}, errorMessage string) { + t.Helper() c, err := NewCodec(schema) if err != nil { t.Fatal(err) @@ -44,14 +46,17 @@ func testTextEncodeFail(t *testing.T, schema string, datum interface{}, errorMes } func testTextEncodeFailBadDatumType(t *testing.T, schema string, datum interface{}) { + t.Helper() testTextEncodeFail(t, schema, datum, "received: ") } func testTextDecodeFailShortBuffer(t *testing.T, schema string, buf []byte) { + t.Helper() testTextDecodeFail(t, schema, buf, "short buffer") } func testTextDecodePass(t *testing.T, schema string, datum interface{}, encoded []byte) { + t.Helper() codec, err := NewCodec(schema) if err != nil { t.Fatalf("schema: %s; %s", schema, err) @@ -213,6 +218,7 @@ func testTextDecodePass(t *testing.T, schema string, datum interface{}, encoded } func testTextEncodePass(t *testing.T, schema string, datum interface{}, expected []byte) { + t.Helper() codec, err := NewCodec(schema) if err != nil { t.Fatalf("Schma: %q %s", schema, err) @@ -230,6 +236,7 @@ func testTextEncodePass(t *testing.T, schema string, datum interface{}, expected // testTextCodecPass does a bi-directional codec check, by encoding datum to // bytes, then decoding bytes back to datum. func testTextCodecPass(t *testing.T, schema string, datum interface{}, buf []byte) { + t.Helper() testTextDecodePass(t, schema, datum, buf) testTextEncodePass(t, schema, datum, buf) }