MCPcopy Create free account
hub / github.com/cli/cli / TestCopyLogWithLinePrefix

Function TestCopyLogWithLinePrefix

pkg/cmd/run/view/view_test.go:2765–2855  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2763var expectedLegacyRunLogOutputWithNoSteps = fmt.Sprintf("%s%s", legacyCoolJobRunWithNoStepLogsLogOutput, legacySadJobRunWithNoStepLogsLogOutput)
2764
2765func TestCopyLogWithLinePrefix(t *testing.T) {
2766 longLine := strings.Repeat("x", 70_000)
2767 readErr := errors.New("reading log failed")
2768 r, w := io.Pipe()
2769 require.NoError(t, r.Close())
2770 defer w.Close()
2771
2772 tests := []struct {
2773 name string
2774 input io.Reader
2775 writer io.Writer
2776 want string
2777 wantErr error
2778 }{
2779 {
2780 name: "empty log",
2781 input: strings.NewReader(""),
2782 writer: io.Discard,
2783 },
2784 {
2785 name: "multiple lines",
2786 input: strings.NewReader("first\nsecond\n"),
2787 writer: io.Discard,
2788 want: "job\tstep\tfirst\njob\tstep\tsecond\n",
2789 },
2790 {
2791 name: "empty lines",
2792 input: strings.NewReader("\n\n"),
2793 writer: io.Discard,
2794 want: "job\tstep\t\njob\tstep\t\n",
2795 },
2796 {
2797 name: "CRLF lines",
2798 input: strings.NewReader("first\r\nsecond\r\n"),
2799 writer: io.Discard,
2800 want: "job\tstep\tfirst\njob\tstep\tsecond\n",
2801 },
2802 {
2803 name: "no final newline",
2804 input: strings.NewReader("last"),
2805 writer: io.Discard,
2806 want: "job\tstep\tlast\n",
2807 },
2808 {
2809 name: "final carriage return",
2810 input: strings.NewReader("last\r"),
2811 writer: io.Discard,
2812 want: "job\tstep\tlast\n",
2813 },
2814 {
2815 name: "long line followed by marker",
2816 input: strings.NewReader(longLine + "\nAFTER-LONG-LINE\n"),
2817 writer: io.Discard,
2818 want: "job\tstep\t" + longLine + "\njob\tstep\tAFTER-LONG-LINE\n",
2819 },
2820 {
2821 name: "long line without final newline",
2822 input: strings.NewReader(longLine),

Callers

nothing calls this directly

Calls 5

copyLogWithLinePrefixFunction · 0.85
EqualMethod · 0.80
CloseMethod · 0.65
RunMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected