Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2022-07-21 07:41:38 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2022-07-21 07:42:13 +0300
commit69674534b5ddb217f467062acc6de9797ed875a4 (patch)
tree6ed26ff36573d0d8800fd9942cb986d55d54b869
parentf8e688fbf64938cf8563f765c040af39f33e0790 (diff)
gittest: Add `Pktlinef()` helper function
Add a helper function that returns a pktline-formatted string. While at it, add missing calls to `t.Helper()`.
-rw-r--r--internal/git/gittest/pktline.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/internal/git/gittest/pktline.go b/internal/git/gittest/pktline.go
index e198f01e0..622719b34 100644
--- a/internal/git/gittest/pktline.go
+++ b/internal/git/gittest/pktline.go
@@ -3,14 +3,25 @@ package gittest
import (
"fmt"
"io"
+ "strings"
"testing"
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/v15/internal/git/pktline"
)
+// Pktlinef formats the given formatting string into a pktline.
+func Pktlinef(t *testing.T, format string, a ...interface{}) string {
+ t.Helper()
+ var builder strings.Builder
+ _, err := pktline.WriteString(&builder, fmt.Sprintf(format, a...))
+ require.NoError(t, err)
+ return builder.String()
+}
+
// WritePktlineString writes the pktline-formatted data into the writer.
func WritePktlineString(t *testing.T, writer io.Writer, data string) {
+ t.Helper()
_, err := pktline.WriteString(writer, data)
require.NoError(t, err)
}
@@ -18,16 +29,19 @@ func WritePktlineString(t *testing.T, writer io.Writer, data string) {
// WritePktlinef formats the given format string and writes the pktline-formatted data into the
// writer.
func WritePktlinef(t *testing.T, writer io.Writer, format string, args ...interface{}) {
+ t.Helper()
_, err := pktline.WriteString(writer, fmt.Sprintf(format, args...))
require.NoError(t, err)
}
// WritePktlineFlush writes the pktline-formatted flush into the writer.
func WritePktlineFlush(t *testing.T, writer io.Writer) {
+ t.Helper()
require.NoError(t, pktline.WriteFlush(writer))
}
// WritePktlineDelim writes the pktline-formatted delimiter into the writer.
func WritePktlineDelim(t *testing.T, writer io.Writer) {
+ t.Helper()
require.NoError(t, pktline.WriteDelim(writer))
}