| 1 | package lfsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/ |
| 2 | |
| 3 | import ( |
| 4 | "bytesscip-go gomod github.com/golang/go/src go1.25.0 bytes/" |
| 5 | "fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/" |
| 6 | "ioscip-go gomod github.com/golang/go/src go1.25.0 io/" |
| 7 | "osscip-go gomod github.com/golang/go/src go1.25.0 os/" |
| 8 | "testingscip-go gomod github.com/golang/go/src go1.25.0 testing/" |
| 9 | |
| 10 | "github.com/git-lfs/git-lfs/v3/configscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/" |
| 11 | "github.com/git-lfs/git-lfs/v3/internal/testutilscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/internal/testutil`/" |
| 12 | "github.com/git-lfs/git-lfs/v3/tasklogscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/" |
| 13 | "github.com/git-lfs/git-lfs/v3/toolsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/" |
| 14 | "github.com/jmhodges/clockscip-go gomod github.com/jmhodges/clock v1.2.0 `github.com/jmhodges/clock`/" |
| 15 | "github.com/stretchr/testify/assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/" |
| 16 | ) |
| 17 | |
| 18 | func TestBothCallbackReadersWithCallbackscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/TestBothCallbackReadersWithCallback().(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#) { |
| 19 | var calls int |
| 20 | allReadSoFar := make([]int64, 0, 2) |
| 21 | |
| 22 | buf := []byte("BOOYA") |
| 23 | bufSize := len(buf) |
| 24 | |
| 25 | cb := func(totalSize int64, readSoFar int64, readSinceLast int) error { |
| 26 | calls++ |
| 27 | allReadSoFar = append(allReadSoFar, readSoFar) |
| 28 | |
| 29 | 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) |
| 30 | |
| 31 | return nil |
| 32 | } |
| 33 | |
| 34 | readBuf := make([]byte, bufSize-2) |
| 35 | readBufSize := len(readBuf) |
| 36 | |
| 37 | r := toolsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/.NewCallbackReaderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/NewCallbackReader().(bytesscip-go gomod github.com/golang/go/src go1.25.0 bytes/.NewReaderscip-go gomod github.com/golang/go/src go1.25.0 bytes/NewReader().(buf), int64(bufSize), cb) |
| 38 | br := toolsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/.NewBodyWithCallbackscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/NewBodyWithCallback().(toolsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/.NewClosingByteReaderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/NewClosingByteReader().(buf), int64(bufSize), cb) |
| 39 | |
| 40 | for _, reader := range []ioscip-go gomod github.com/golang/go/src go1.25.0 io/.Readerscip-go gomod github.com/golang/go/src go1.25.0 io/Reader#{r, br} { |
| 41 | t.Logfscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Logf().("testing with reader: %T", reader) |
| 42 | |
| 43 | n, err := reader.Readscip-go gomod github.com/golang/go/src go1.25.0 io/Reader#Read().(readBuf) |
| 44 | |
| 45 | // The underlying bytes.Reader should always return |
| 46 | // a nil error when the last byte is read. |
| 47 | 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, readBufSize, n) |
| 48 | 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) |
| 49 | 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, buf[:readBufSize], readBuf) |
| 50 | |
| 51 | n, err = reader.Readscip-go gomod github.com/golang/go/src go1.25.0 io/Reader#Read().(readBuf) |
| 52 | |
| 53 | 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-readBufSize, n) |
| 54 | 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) |
| 55 | 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, buf[readBufSize:], readBuf[:bufSize-readBufSize]) |
| 56 | |
| 57 | 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, 2, calls) |
| 58 | 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, 2) |
| 59 | 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, readBufSize, allReadSoFar[0]) |
| 60 | 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[1]) |
| 61 | |
| 62 | calls = 0 |
| 63 | allReadSoFar = allReadSoFar[:0] |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | type copyCallbackFileThrottleTestModescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestMode# int |
| 68 | |
| 69 | const ( |
| 70 | initialTotalCorrectscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/initialTotalCorrect. copyCallbackFileThrottleTestModescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestMode# = iota |
| 71 | initialTotalOverestimatedscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/initialTotalOverestimated. |
| 72 | initialTotalUnderestimatedscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/initialTotalUnderestimated. |
| 73 | initialTotalUnknownscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/initialTotalUnknown. |
| 74 | ) |
| 75 | |
| 76 | type copyCallbackFileThrottleTestCasescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase# struct { |
| 77 | modescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#mode. copyCallbackFileThrottleTestModescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestMode# |
| 78 | readerBufSizescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#readerBufSize. int64 |
| 79 | delayedEOFscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#delayedEOF. bool |
| 80 | |
| 81 | logFilePathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#logFilePath. string |
| 82 | fakeClockscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#fakeClock. clockscip-go gomod github.com/jmhodges/clock v1.2.0 `github.com/jmhodges/clock`/.FakeClockscip-go gomod github.com/jmhodges/clock v1.2.0 `github.com/jmhodges/clock`/FakeClock# |
| 83 | callbackReaderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#callbackReader. *toolsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/.CallbackReaderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/CallbackReader# |
| 84 | |
| 85 | expectedFractionsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#expectedFractions. []string |
| 86 | } |
| 87 | |
| 88 | func (c *copyCallbackFileThrottleTestCasescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#) setupscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#setup().(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#) (*osscip-go gomod github.com/golang/go/src go1.25.0 os/.Filescip-go gomod github.com/golang/go/src go1.25.0 os/File#, error) { |
| 89 | tmpDir := t.TempDirscip-go gomod github.com/golang/go/src go1.25.0 testing/common#TempDir().() |
| 90 | c.logFilePathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#logFilePath. = tmpDir + "/git_lfs_progress.log" |
| 91 | osMf := configscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/.UniqMapFetcherscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/UniqMapFetcher().(map[string]string{ |
| 92 | "GIT_LFS_PROGRESS": c.logFilePathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#logFilePath., |
| 93 | }) |
| 94 | gitMf := configscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/.UniqMapFetcherscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/UniqMapFetcher().(map[string]string{}) |
| 95 | |
| 96 | c.fakeClockscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#fakeClock. = clockscip-go gomod github.com/jmhodges/clock v1.2.0 `github.com/jmhodges/clock`/.NewFakescip-go gomod github.com/jmhodges/clock v1.2.0 `github.com/jmhodges/clock`/NewFake().() |
| 97 | gf := GitFilterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/GitFilter#{ |
| 98 | cfgscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/GitFilter#cfg.: &configscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/.Configurationscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Configuration#{ |
| 99 | Osscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Configuration#Os.: configscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/.EnvironmentOfscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/EnvironmentOf().(osMf), |
| 100 | Gitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Configuration#Git.: configscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/.EnvironmentOfscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/EnvironmentOf().(gitMf), |
| 101 | }, |
| 102 | clkscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/GitFilter#clk.: c.fakeClockscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#fakeClock., |
| 103 | } |
| 104 | |
| 105 | cb, f, err := gf.CopyCallbackFilescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/GitFilter#CopyCallbackFile().("clean", "test_copy", 1, 1) |
| 106 | if err != nil { |
| 107 | return f, fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Errorf().("unable to create progress log callback: %w", err) |
| 108 | } |
| 109 | |
| 110 | // The Assert() method requires at least four separate reads, |
| 111 | // and three additional reads if we are simulating an underestimated |
| 112 | // initial total size. |
| 113 | bufSize := 4 * c.readerBufSizescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#readerBufSize. |
| 114 | initialTotalSize := bufSize |
| 115 | switch c.modescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#mode. { |
| 116 | case initialTotalOverestimatedscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/initialTotalOverestimated.: |
| 117 | bufSize -= c.readerBufSizescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#readerBufSize. |
| 118 | case initialTotalUnderestimatedscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/initialTotalUnderestimated.: |
| 119 | bufSize += 3 * c.readerBufSizescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#readerBufSize. |
| 120 | case initialTotalUnknownscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/initialTotalUnknown.: |
| 121 | initialTotalSize = -1 |
| 122 | } |
| 123 | |
| 124 | buf := make([]byte, bufSize) |
| 125 | |
| 126 | var r ioscip-go gomod github.com/golang/go/src go1.25.0 io/.Readerscip-go gomod github.com/golang/go/src go1.25.0 io/Reader# |
| 127 | if c.delayedEOFscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#delayedEOF. { |
| 128 | r = testutilscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/internal/testutil`/.NewDeferredEOFByteReaderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/internal/testutil`/NewDeferredEOFByteReader().(buf) |
| 129 | } else { |
| 130 | r = testutilscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/internal/testutil`/.NewEagerEOFByteReaderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/internal/testutil`/NewEagerEOFByteReader().(buf) |
| 131 | } |
| 132 | |
| 133 | c.callbackReaderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#callbackReader. = toolsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/.NewCallbackReaderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/NewCallbackReader().(r, initialTotalSize, cb) |
| 134 | |
| 135 | return f, err |
| 136 | } |
| 137 | |
| 138 | func (c *copyCallbackFileThrottleTestCasescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#) Assertscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#Assert().(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#) { |
| 139 | buf := make([]byte, c.readerBufSizescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#readerBufSize.) |
| 140 | |
| 141 | // Read #1: No message should be logged as the deadline has not passed. |
| 142 | n, err := c.callbackReaderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#callbackReader..Readscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/CallbackReader#Read().(buf) |
| 143 | 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, c.readerBufSizescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#readerBufSize., n) |
| 144 | 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) |
| 145 | |
| 146 | c.fakeClockscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#fakeClock..Addscip-go gomod github.com/jmhodges/clock v1.2.0 `github.com/jmhodges/clock`/FakeClock#Add().(tasklogscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/.DefaultLoggingThrottlescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/DefaultLoggingThrottle.) |
| 147 | |
| 148 | // Read #2: A message should be logged as the deadline has passed. |
| 149 | n, err = c.callbackReaderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#callbackReader..Readscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/CallbackReader#Read().(buf) |
| 150 | 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, c.readerBufSizescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#readerBufSize., n) |
| 151 | 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) |
| 152 | |
| 153 | c.fakeClockscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#fakeClock..Addscip-go gomod github.com/jmhodges/clock v1.2.0 `github.com/jmhodges/clock`/FakeClock#Add().(tasklogscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/.DefaultLoggingThrottlescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/DefaultLoggingThrottle. / 2) |
| 154 | |
| 155 | // Read #3: When the total size was initially correct, unknown, or |
| 156 | // underestimated, or when EOF is delayed, no message |
| 157 | // should be logged as the full deadline has not passed. |
| 158 | // |
| 159 | // However, when the total size was initially overestimated |
| 160 | // and EOF is not delayed, a message should be logged |
| 161 | // because the actual total is now known. |
| 162 | n, err = c.callbackReaderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#callbackReader..Readscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/CallbackReader#Read().(buf) |
| 163 | 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, c.readerBufSizescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#readerBufSize., n) |
| 164 | if c.modescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#mode. != initialTotalOverestimatedscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/initialTotalOverestimated. || c.delayedEOFscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#delayedEOF. { |
| 165 | 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) |
| 166 | } else { |
| 167 | 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) |
| 168 | } |
| 169 | |
| 170 | if c.modescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#mode. != initialTotalOverestimatedscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/initialTotalOverestimated. { |
| 171 | // Read #4: When the total size was initially unknown and |
| 172 | // EOF is delayed, no message should be logged as |
| 173 | // the full deadline has not passed. |
| 174 | // |
| 175 | // Otherwise, a message should be logged even though |
| 176 | // the full deadline has not passed either because |
| 177 | // the initial total has been reached or because the |
| 178 | // actual total is now known. |
| 179 | n, err = c.callbackReaderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#callbackReader..Readscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/CallbackReader#Read().(buf) |
| 180 | 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, c.readerBufSizescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#readerBufSize., n) |
| 181 | if c.modescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#mode. == initialTotalUnderestimatedscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/initialTotalUnderestimated. || c.delayedEOFscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#delayedEOF. { |
| 182 | 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) |
| 183 | } else { |
| 184 | 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) |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | if c.modescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#mode. == initialTotalUnderestimatedscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/initialTotalUnderestimated. { |
| 189 | // Read #5: No message should be logged as the deadline |
| 190 | // has not passed, even though the initial total |
| 191 | // has been exceeded. |
| 192 | n, err = c.callbackReaderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#callbackReader..Readscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/CallbackReader#Read().(buf) |
| 193 | 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, c.readerBufSizescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#readerBufSize., n) |
| 194 | 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) |
| 195 | |
| 196 | c.fakeClockscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#fakeClock..Addscip-go gomod github.com/jmhodges/clock v1.2.0 `github.com/jmhodges/clock`/FakeClock#Add().(tasklogscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/.DefaultLoggingThrottlescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/DefaultLoggingThrottle.) |
| 197 | |
| 198 | // Read #6: A message should be logged as the deadline |
| 199 | // has passed, even though the initial total |
| 200 | // has been exceeded. |
| 201 | n, err = c.callbackReaderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#callbackReader..Readscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/CallbackReader#Read().(buf) |
| 202 | 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, c.readerBufSizescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#readerBufSize., n) |
| 203 | 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) |
| 204 | |
| 205 | // Read #7: When EOF is delayed, no message should be logged |
| 206 | // as the deadline has not passed, even though the |
| 207 | // initial total has been exceeded. |
| 208 | // |
| 209 | // Otherwise, a message should be logged even though |
| 210 | // the deadline has not passed because the actual |
| 211 | // total is now known. |
| 212 | n, err = c.callbackReaderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#callbackReader..Readscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/CallbackReader#Read().(buf) |
| 213 | 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, c.readerBufSizescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#readerBufSize., n) |
| 214 | if c.delayedEOFscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#delayedEOF. { |
| 215 | 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) |
| 216 | } else { |
| 217 | 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) |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | if c.delayedEOFscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#delayedEOF. { |
| 222 | // Final EOF Read: When the total size was initially correct, |
| 223 | // no callback should be made and so no |
| 224 | // message should be logged. |
| 225 | // |
| 226 | // Otherwise, a message should be logged |
| 227 | // as the actual total is now known, even |
| 228 | // though the deadline has not passed. |
| 229 | n, err = c.callbackReaderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#callbackReader..Readscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/CallbackReader#Read().(buf) |
| 230 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Zeroscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Zero().(t, n) |
| 231 | 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) |
| 232 | } |
| 233 | |
| 234 | logBytes, err := osscip-go gomod github.com/golang/go/src go1.25.0 os/.ReadFilescip-go gomod github.com/golang/go/src go1.25.0 os/ReadFile().(c.logFilePathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#logFilePath.) |
| 235 | 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) |
| 236 | |
| 237 | var expectedLog string |
| 238 | for _, expectedFraction := range c.expectedFractionsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#expectedFractions. { |
| 239 | expectedLog += fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Sprintf().("clean 1/1 %s test_copy\n", expectedFraction) |
| 240 | } |
| 241 | |
| 242 | 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, expectedLog, string(logBytes)) |
| 243 | } |
| 244 | |
| 245 | func TestCopyCallbackFileThrottlescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/TestCopyCallbackFileThrottle().(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#) { |
| 246 | for desc, c := range map[string]*copyCallbackFileThrottleTestCasescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#{ |
| 247 | "initial total correct": { |
| 248 | modescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#mode.: initialTotalCorrectscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/initialTotalCorrect., |
| 249 | readerBufSizescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#readerBufSize.: 32 * 1024, |
| 250 | expectedFractionsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#expectedFractions.: []string{ |
| 251 | "65536/131072", |
| 252 | "131072/131072", |
| 253 | }, |
| 254 | }, |
| 255 | "initial total overestimated": { |
| 256 | modescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#mode.: initialTotalOverestimatedscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/initialTotalOverestimated., |
| 257 | readerBufSizescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#readerBufSize.: 32 * 1024, |
| 258 | expectedFractionsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#expectedFractions.: []string{ |
| 259 | "65536/131072", |
| 260 | "98304/98304", |
| 261 | }, |
| 262 | }, |
| 263 | "initial total underestimated": { |
| 264 | modescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#mode.: initialTotalUnderestimatedscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/initialTotalUnderestimated., |
| 265 | readerBufSizescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#readerBufSize.: 32 * 1024, |
| 266 | expectedFractionsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#expectedFractions.: []string{ |
| 267 | "65536/131072", |
| 268 | "131072/131072", |
| 269 | "196608/131072", |
| 270 | "229376/229376", |
| 271 | }, |
| 272 | }, |
| 273 | "initial total unknown": { |
| 274 | modescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#mode.: initialTotalUnknownscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/initialTotalUnknown., |
| 275 | readerBufSizescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#readerBufSize.: 32 * 1024, |
| 276 | expectedFractionsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#expectedFractions.: []string{ |
| 277 | "65536/?????", |
| 278 | "131072/131072", |
| 279 | }, |
| 280 | }, |
| 281 | } { |
| 282 | for _, delayedEOF := range []bool{false, true} { |
| 283 | if delayedEOF { |
| 284 | c.delayedEOFscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#delayedEOF. = true |
| 285 | desc += " with delayed EOF" |
| 286 | } |
| 287 | |
| 288 | f, err := c.setupscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#setup().(t) |
| 289 | if err != nil { |
| 290 | t.Errorscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Error().(err) |
| 291 | continue |
| 292 | } |
| 293 | defer f.Closescip-go gomod github.com/golang/go/src go1.25.0 os/File#Close().() |
| 294 | |
| 295 | t.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Run().(desc, c.Assertscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/copyCallbackFileThrottleTestCase#Assert().) |
| 296 | } |
| 297 | } |
| 298 | } |