Debian Codegraph @

tools/iotools_test.go

raw symbols SCIP
1 package toolsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/
2
3 import (
4 "bytesscip-go gomod github.com/golang/go/src go1.25.0 bytes/"
5 "ioscip-go gomod github.com/golang/go/src go1.25.0 io/"
6 "testingscip-go gomod github.com/golang/go/src go1.25.0 testing/"
7
8 "github.com/git-lfs/git-lfs/v3/errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/"
9 "github.com/stretchr/testify/assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/"
10 )
11
12 func TestCopyWithCallbackscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/TestCopyWithCallback().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) {
13 var calls int
14 allReadSoFar := make([]int64, 0, 2)
15
16 buf := bytesscip-go gomod github.com/golang/go/src go1.25.0 bytes/.NewBufferStringscip-go gomod github.com/golang/go/src go1.25.0 bytes/NewBufferString().("BOOYA")
17 bufSize := buf.Lenscip-go gomod github.com/golang/go/src go1.25.0 bytes/Buffer#Len().()
18
19 cb := func(totalSize int64, readSoFar int64, readSinceLast int) error {
20 calls++
21 allReadSoFar = append(allReadSoFar, readSoFar)
22
23 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.EqualValuesscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/EqualValues().(t, bufSize, totalSize)
24
25 return nil
26 }
27
28 n, err := CopyWithCallbackscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/CopyWithCallback().(ioscip-go gomod github.com/golang/go/src go1.25.0 io/.Discardscip-go gomod github.com/golang/go/src go1.25.0 io/Discard., buf, int64(bufSize), cb)
29
30 // The underlying bytes.Buffer should always return a nil error
31 // when the last byte is read.
32 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Nil().(t, err)
33 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.EqualValuesscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/EqualValues().(t, bufSize, n)
34
35 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, 1, calls)
36 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Lenscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Len().(t, allReadSoFar, 1)
37 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.EqualValuesscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/EqualValues().(t, bufSize, allReadSoFar[0])
38 }
39
40 func TestClosingByteReaderNopClosescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/TestClosingByteReaderNopClose().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) {
41 buf := []byte{0x1}
42 bufSize := len(buf)
43
44 r := NewClosingByteReaderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/NewClosingByteReader().(buf)
45
46 // The underlying bytes.Reader has no Close() method and so reads
47 // should still proceed.
48 err := r.Closescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ClosingByteReader#Close().()
49
50 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Nil().(t, err)
51
52 p := make([]byte, bufSize+1)
53
54 n, err := r.Readscip-go gomod github.com/golang/go/src go1.25.0 bytes/Reader#Read().(p)
55
56 // The underlying bytes.Reader should always return
57 // a nil error when the last byte is read.
58 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, bufSize, n)
59 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Nil().(t, err)
60 }
61
62 func TestRetriableReaderReturnsSuccessfulReadsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/TestRetriableReaderReturnsSuccessfulReads().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) {
63 r := NewRetriableReaderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/NewRetriableReader().(bytesscip-go gomod github.com/golang/go/src go1.25.0 bytes/.NewBufferscip-go gomod github.com/golang/go/src go1.25.0 bytes/NewBuffer().([]byte{0x1, 0x2, 0x3, 0x4}))
64
65 var buf [4]byte
66 n, err := r.Readscip-go gomod github.com/golang/go/src go1.25.0 io/Reader#Read().(buf[:])
67
68 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Nil().(t, err)
69 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, 4, n)
70 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, []byte{0x1, 0x2, 0x3, 0x4}, buf[:])
71 }
72
73 func TestRetriableReaderReturnsEOFsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/TestRetriableReaderReturnsEOFs().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) {
74 r := NewRetriableReaderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/NewRetriableReader().(bytesscip-go gomod github.com/golang/go/src go1.25.0 bytes/.NewBufferscip-go gomod github.com/golang/go/src go1.25.0 bytes/NewBuffer().([]byte{ /* empty */ }))
75
76 var buf [1]byte
77 n, err := r.Readscip-go gomod github.com/golang/go/src go1.25.0 io/Reader#Read().(buf[:])
78
79 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, ioscip-go gomod github.com/golang/go/src go1.25.0 io/.EOFscip-go gomod github.com/golang/go/src go1.25.0 io/EOF., err)
80 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, 0, n)
81 }
82
83 func TestRetriableReaderMakesErrorsRetriablescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/TestRetriableReaderMakesErrorsRetriable().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) {
84 expected := errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.Newscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/New().("example error")
85
86 r := NewRetriableReaderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/NewRetriableReader().(&ErrReaderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ErrReader#{expected})
87
88 var buf [1]byte
89 n, err := r.Readscip-go gomod github.com/golang/go/src go1.25.0 io/Reader#Read().(buf[:])
90
91 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, 0, n)
92 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.EqualErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/EqualError().(t, err, "LFS: "+expected.Error())
93 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Truescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/True().(t, errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.IsRetriableErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/IsRetriableError().(err))
94
95 }
96
97 func TestRetriableReaderDoesNotRewrapscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/TestRetriableReaderDoesNotRewrap().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) {
98 // expected is already "retriable", as would be the case if the
99 // underlying reader was a *RetriableReader itself.
100 expected := errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.NewRetriableErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/NewRetriableError().(errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.Newscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/New().("example error"))
101
102 r := NewRetriableReaderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/NewRetriableReader().(&ErrReaderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ErrReader#{expected})
103
104 var buf [1]byte
105 n, err := r.Readscip-go gomod github.com/golang/go/src go1.25.0 io/Reader#Read().(buf[:])
106
107 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, 0, n)
108 // errors.NewRetriableError wraps the given error with the prefix
109 // message "LFS", so these two errors should be equal, indicating that
110 // the RetriableReader did not re-wrap the error it received.
111 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.EqualErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/EqualError().(t, err, expected.Error())
112 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Truescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/True().(t, errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.IsRetriableErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/IsRetriableError().(err))
113
114 }
115
116 // ErrReader implements io.Reader and only returns errors.
117 type ErrReaderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ErrReader# struct {
118 // err is the error that this reader will return.
119 errscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ErrReader#err. error
120 }
121
122 // Read implements io.Reader#Read, and returns (0, e.err).
123 func (e *ErrReaderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ErrReader#) Readscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ErrReader#Read().(p []byte) (n int, err error) {
124 return 0, e.errscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ErrReader#err.
125 }