| 1 | package tqscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/ |
| 2 | |
| 3 | import ( |
| 4 | "testingscip-go gomod github.com/golang/go/src go1.25.0 testing/" |
| 5 | "timescip-go gomod github.com/golang/go/src go1.25.0 time/" |
| 6 | |
| 7 | "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`/" |
| 8 | "github.com/git-lfs/git-lfs/v3/lfsapiscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/" |
| 9 | "github.com/git-lfs/git-lfs/v3/lfshttpscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/" |
| 10 | "github.com/stretchr/testify/assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/" |
| 11 | ) |
| 12 | |
| 13 | func TestManifestDefaultsToFixedRetriesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/TestManifestDefaultsToFixedRetries().(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#) { |
| 14 | cli := lfsapiscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/.NewClientscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/NewClient().(nil) |
| 15 | defer cli.Closescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#Close().() |
| 16 | |
| 17 | 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, 8, NewManifestscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/NewManifest().(nil, cli, "", "").MaxRetriesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Manifest#MaxRetries.()) |
| 18 | } |
| 19 | |
| 20 | func TestManifestDefaultsToFixedRetryDelayscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/TestManifestDefaultsToFixedRetryDelay().(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#) { |
| 21 | cli := lfsapiscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/.NewClientscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/NewClient().(nil) |
| 22 | defer cli.Closescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#Close().() |
| 23 | |
| 24 | 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, 10, NewManifestscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/NewManifest().(nil, cli, "", "").MaxRetryDelayscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Manifest#MaxRetryDelay.()) |
| 25 | } |
| 26 | |
| 27 | func TestRetryCounterDefaultsToFixedRetriesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/TestRetryCounterDefaultsToFixedRetries().(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#) { |
| 28 | rc := newRetryCounterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/newRetryCounter().() |
| 29 | 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, 8, rc.MaxRetriesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/retryCounter#MaxRetries.) |
| 30 | } |
| 31 | |
| 32 | func TestRetryCounterDefaultsToFixedRetryDelayscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/TestRetryCounterDefaultsToFixedRetryDelay().(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#) { |
| 33 | rc := newRetryCounterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/newRetryCounter().() |
| 34 | 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, 10, rc.MaxRetryDelayscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/retryCounter#MaxRetryDelay.) |
| 35 | } |
| 36 | |
| 37 | func TestRetryCounterIncrementsObjectsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/TestRetryCounterIncrementsObjects().(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#) { |
| 38 | rc := newRetryCounterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/newRetryCounter().() |
| 39 | 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, rc.Incrementscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/retryCounter#Increment().("oid")) |
| 40 | 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, rc.CountForscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/retryCounter#CountFor().("oid")) |
| 41 | |
| 42 | 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, rc.Incrementscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/retryCounter#Increment().("oid")) |
| 43 | 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, rc.CountForscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/retryCounter#CountFor().("oid")) |
| 44 | } |
| 45 | |
| 46 | func TestRetryCounterCanNotRetryAfterExceedingRetryCountscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/TestRetryCounterCanNotRetryAfterExceedingRetryCount().(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#) { |
| 47 | rc := newRetryCounterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/newRetryCounter().() |
| 48 | rc.MaxRetriesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/retryCounter#MaxRetries. = 1 |
| 49 | rc.Incrementscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/retryCounter#Increment().("oid") |
| 50 | |
| 51 | count, canRetry := rc.CanRetryscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/retryCounter#CanRetry().("oid") |
| 52 | 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, count) |
| 53 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Falsescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/False().(t, canRetry) |
| 54 | } |
| 55 | |
| 56 | func TestRetryCounterDoesNotDelayFirstAttemptscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/TestRetryCounterDoesNotDelayFirstAttempt().(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#) { |
| 57 | rc := newRetryCounterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/newRetryCounter().() |
| 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, timescip-go gomod github.com/golang/go/src go1.25.0 time/.Timescip-go gomod github.com/golang/go/src go1.25.0 time/Time#{}, rc.ReadyTimescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/retryCounter#ReadyTime().("oid")) |
| 59 | } |
| 60 | |
| 61 | func TestRetryCounterDelaysExponentiallyscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/TestRetryCounterDelaysExponentially().(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#) { |
| 62 | rc := newRetryCounterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/newRetryCounter().() |
| 63 | start := timescip-go gomod github.com/golang/go/src go1.25.0 time/.Nowscip-go gomod github.com/golang/go/src go1.25.0 time/Now().() |
| 64 | |
| 65 | rc.Incrementscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/retryCounter#Increment().("oid") |
| 66 | ready1 := rc.ReadyTimescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/retryCounter#ReadyTime().("oid") |
| 67 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.GreaterOrEqualscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/GreaterOrEqual().(t, int64(ready1.Subscip-go gomod github.com/golang/go/src go1.25.0 time/Time#Sub().(start)/timescip-go gomod github.com/golang/go/src go1.25.0 time/.Millisecondscip-go gomod github.com/golang/go/src go1.25.0 time/Millisecond.), int64(baseRetryDelayMsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/baseRetryDelayMs.)) |
| 68 | |
| 69 | rc.Incrementscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/retryCounter#Increment().("oid") |
| 70 | ready2 := rc.ReadyTimescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/retryCounter#ReadyTime().("oid") |
| 71 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.GreaterOrEqualscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/GreaterOrEqual().(t, int64(ready2.Subscip-go gomod github.com/golang/go/src go1.25.0 time/Time#Sub().(start)/timescip-go gomod github.com/golang/go/src go1.25.0 time/.Millisecondscip-go gomod github.com/golang/go/src go1.25.0 time/Millisecond.), int64(2*baseRetryDelayMsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/baseRetryDelayMs.)) |
| 72 | } |
| 73 | |
| 74 | func TestRetryCounterLimitsDelayscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/TestRetryCounterLimitsDelay().(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#) { |
| 75 | rc := newRetryCounterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/newRetryCounter().() |
| 76 | rc.MaxRetryDelayscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/retryCounter#MaxRetryDelay. = 1 |
| 77 | |
| 78 | for i := 0; i < 4; i++ { |
| 79 | rc.Incrementscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/retryCounter#Increment().("oid") |
| 80 | } |
| 81 | |
| 82 | rt := rc.ReadyTimescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/retryCounter#ReadyTime().("oid") |
| 83 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.WithinDurationscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/WithinDuration().(t, timescip-go gomod github.com/golang/go/src go1.25.0 time/.Nowscip-go gomod github.com/golang/go/src go1.25.0 time/Now().(), rt, 1*timescip-go gomod github.com/golang/go/src go1.25.0 time/.Secondscip-go gomod github.com/golang/go/src go1.25.0 time/Second.) |
| 84 | } |
| 85 | |
| 86 | func TestBatchSizeReturnsBatchSizescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/TestBatchSizeReturnsBatchSize().(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#) { |
| 87 | cli := lfsapiscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/.NewClientscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/NewClient().(nil) |
| 88 | defer cli.Closescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#Close().() |
| 89 | |
| 90 | q := NewTransferQueuescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/NewTransferQueue().( |
| 91 | Uploadscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Upload., NewManifestscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/NewManifest().(nil, cli, "", ""), "origin", WithBatchSizescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/WithBatchSize().(3), |
| 92 | ) |
| 93 | |
| 94 | 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, 3, q.BatchSizescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/TransferQueue#BatchSize().()) |
| 95 | } |
| 96 | |
| 97 | func TestUseAdapterReusesWhenNameMatchesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/TestUseAdapterReusesWhenNameMatches().(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 | cli := lfsapiscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/.NewClientscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/NewClient().(nil) |
| 99 | defer cli.Closescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#Close().() |
| 100 | |
| 101 | q := NewTransferQueuescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/NewTransferQueue().( |
| 102 | Downloadscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Download., NewManifestscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/NewManifest().(nil, cli, "", ""), "origin", |
| 103 | ) |
| 104 | |
| 105 | // Set an initial adapter. |
| 106 | q.useAdapterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/TransferQueue#useAdapter().("basic") |
| 107 | first := q.adapterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/TransferQueue#adapter. |
| 108 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.NotNilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/NotNil().(t, first) |
| 109 | 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, "basic", first.Namescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Adapter#Name.()) |
| 110 | |
| 111 | // Calling with the same name should reuse the adapter instance. |
| 112 | q.useAdapterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/TransferQueue#useAdapter().("basic") |
| 113 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Samescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Same().(t, first, q.adapterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/TransferQueue#adapter., "expected adapter to be reused when name matches") |
| 114 | } |
| 115 | |
| 116 | func TestUseAdapterReusesWhenNameIsEmptyscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/TestUseAdapterReusesWhenNameIsEmpty().(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#) { |
| 117 | cli := lfsapiscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/.NewClientscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/NewClient().(nil) |
| 118 | defer cli.Closescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#Close().() |
| 119 | |
| 120 | q := NewTransferQueuescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/NewTransferQueue().( |
| 121 | Downloadscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Download., NewManifestscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/NewManifest().(nil, cli, "", ""), "origin", |
| 122 | ) |
| 123 | |
| 124 | q.useAdapterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/TransferQueue#useAdapter().("basic") |
| 125 | first := q.adapterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/TransferQueue#adapter. |
| 126 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.NotNilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/NotNil().(t, first) |
| 127 | |
| 128 | // An empty name means "use basic" per the spec. Since the current |
| 129 | // adapter is already basic, it should be reused. |
| 130 | q.useAdapterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/TransferQueue#useAdapter().("") |
| 131 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Samescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Same().(t, first, q.adapterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/TransferQueue#adapter., "expected basic adapter to be reused when name is empty") |
| 132 | } |
| 133 | |
| 134 | func TestUseAdapterSwitchesFromNonDefaultWhenNameIsEmptyscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/TestUseAdapterSwitchesFromNonDefaultWhenNameIsEmpty().(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#) { |
| 135 | cli := lfsapiscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/.NewClientscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/NewClient().(nil) |
| 136 | defer cli.Closescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#Close().() |
| 137 | |
| 138 | q := NewTransferQueuescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/NewTransferQueue().( |
| 139 | Downloadscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Download., NewManifestscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/NewManifest().(nil, cli, "", ""), "origin", |
| 140 | ) |
| 141 | |
| 142 | q.useAdapterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/TransferQueue#useAdapter().("ssh") |
| 143 | first := q.adapterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/TransferQueue#adapter. |
| 144 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.NotNilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/NotNil().(t, first) |
| 145 | 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, "ssh", first.Namescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Adapter#Name.()) |
| 146 | |
| 147 | // An empty name means "use basic" per the spec, so it should |
| 148 | // switch away from the SSH adapter. |
| 149 | q.useAdapterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/TransferQueue#useAdapter().("") |
| 150 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.NotSamescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/NotSame().(t, first, q.adapterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/TransferQueue#adapter., "expected adapter to switch from ssh to basic") |
| 151 | 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, "basic", q.adapterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/TransferQueue#adapter..Namescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Adapter#Name.()) |
| 152 | } |
| 153 | |
| 154 | func TestUseAdapterSwitchesWhenNameDiffersscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/TestUseAdapterSwitchesWhenNameDiffers().(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#) { |
| 155 | cli := lfsapiscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/.NewClientscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/NewClient().(nil) |
| 156 | defer cli.Closescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#Close().() |
| 157 | |
| 158 | q := NewTransferQueuescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/NewTransferQueue().( |
| 159 | Downloadscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Download., NewManifestscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/NewManifest().(nil, cli, "", ""), "origin", |
| 160 | ) |
| 161 | |
| 162 | q.useAdapterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/TransferQueue#useAdapter().("basic") |
| 163 | first := q.adapterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/TransferQueue#adapter. |
| 164 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.NotNilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/NotNil().(t, first) |
| 165 | |
| 166 | // A different, non-empty name should cause the adapter to switch. |
| 167 | q.useAdapterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/TransferQueue#useAdapter().("ssh") |
| 168 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.NotNilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/NotNil().(t, q.adapterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/TransferQueue#adapter.) |
| 169 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.NotSamescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/NotSame().(t, first, q.adapterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/TransferQueue#adapter., "expected a new adapter when name differs") |
| 170 | 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, "ssh", q.adapterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/TransferQueue#adapter..Namescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Adapter#Name.()) |
| 171 | } |
| 172 | |
| 173 | func TestCanRetryObjectLaterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/TestCanRetryObjectLater().(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#) { |
| 174 | cli := lfsapiscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/.NewClientscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/NewClient().( |
| 175 | lfshttpscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/.NewContextscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/NewContext().( |
| 176 | nil, |
| 177 | nil, |
| 178 | map[string]string{ |
| 179 | "lfs.transfer.maxretrytime": "5", |
| 180 | }, |
| 181 | ), |
| 182 | ) |
| 183 | defer cli.Closescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#Close().() |
| 184 | |
| 185 | tests := []struct { |
| 186 | name string |
| 187 | err error |
| 188 | setup func(*TransferQueuescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/TransferQueue#) |
| 189 | expectedCanRetry bool |
| 190 | expectedReadyTimeZero bool |
| 191 | }{ |
| 192 | { |
| 193 | name: "retry count exceeded", |
| 194 | err: errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.NewRetriableLaterErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/NewRetriableLaterError().(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().("rate limit"), "10"), |
| 195 | setup: func(q *TransferQueuescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/TransferQueue#) { |
| 196 | q.rcscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/TransferQueue#rc..MaxRetriesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/retryCounter#MaxRetries. = 1 |
| 197 | q.rcscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/TransferQueue#rc..Incrementscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/retryCounter#Increment().("oid") |
| 198 | }, |
| 199 | expectedReadyTimeZero: true, |
| 200 | }, |
| 201 | { |
| 202 | name: "non-retriable-later error", |
| 203 | err: 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().("network error")), |
| 204 | expectedReadyTimeZero: true, |
| 205 | }, |
| 206 | { |
| 207 | name: "retry-after exceeds threshold", |
| 208 | err: errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.NewRetriableLaterErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/NewRetriableLaterError().(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().("rate limit"), "10"), |
| 209 | expectedReadyTimeZero: true, |
| 210 | }, |
| 211 | { |
| 212 | name: "retry-after within threshold", |
| 213 | err: errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.NewRetriableLaterErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/NewRetriableLaterError().(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().("rate limit"), "3"), |
| 214 | expectedCanRetry: true, |
| 215 | }, |
| 216 | } |
| 217 | |
| 218 | for _, tt := range tests { |
| 219 | t.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Run().(tt.name, func(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#) { |
| 220 | q := NewTransferQueuescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/NewTransferQueue().( |
| 221 | Downloadscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Download., |
| 222 | NewManifestscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/NewManifest().(nil, cli, "", ""), |
| 223 | "origin", |
| 224 | ) |
| 225 | |
| 226 | if tt.setup != nil { |
| 227 | tt.setup(q) |
| 228 | } |
| 229 | |
| 230 | retryAt, canRetry := q.canRetryObjectLaterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/TransferQueue#canRetryObjectLater().("oid", tt.err) |
| 231 | |
| 232 | 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, tt.expectedCanRetry, canRetry) |
| 233 | 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, tt.expectedReadyTimeZero, retryAt.IsZeroscip-go gomod github.com/golang/go/src go1.25.0 time/Time#IsZero().()) |
| 234 | }) |
| 235 | } |
| 236 | } |