| 1 | package tasklogscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/ |
| 2 | |
| 3 | import ( |
| 4 | "testingscip-go gomod github.com/golang/go/src go1.25.0 testing/" |
| 5 | |
| 6 | "github.com/stretchr/testify/assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/" |
| 7 | ) |
| 8 | |
| 9 | func TestPercentageTaskCalculuatesPercentagesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/TestPercentageTaskCalculuatesPercentages().(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#) { |
| 10 | task := NewPercentageTaskscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/NewPercentageTask().("example", 10) |
| 11 | |
| 12 | 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, "example: 0% (0/10)", (<-task.Updatesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/PercentageTask#Updates().()).Sscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/Update#S.) |
| 13 | |
| 14 | n := task.Countscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/PercentageTask#Count().(3) |
| 15 | 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, 3, n) |
| 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, "example: 30% (3/10)", (<-task.Updatesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/PercentageTask#Updates().()).Sscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/Update#S.) |
| 18 | } |
| 19 | |
| 20 | func TestPercentageTaskCalculatesPercentWithoutTotalscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/TestPercentageTaskCalculatesPercentWithoutTotal().(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 | task := NewPercentageTaskscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/NewPercentageTask().("example", 0) |
| 22 | |
| 23 | select { |
| 24 | case v, ok := <-task.Updatesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/PercentageTask#Updates().(): |
| 25 | if ok { |
| 26 | 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, "example: 100% (0/0)", v.Sscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/Update#S.) |
| 27 | } else { |
| 28 | t.Fatalscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Fatal().("expected channel to be open") |
| 29 | } |
| 30 | default: |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | func TestPercentageTaskCallsDoneWhenCompletescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/TestPercentageTaskCallsDoneWhenComplete().(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#) { |
| 35 | task := NewPercentageTaskscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/NewPercentageTask().("example", 10) |
| 36 | |
| 37 | select { |
| 38 | case v, ok := <-task.Updatesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/PercentageTask#Updates().(): |
| 39 | if ok { |
| 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, "example: 0% (0/10)", v.Sscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/Update#S.) |
| 41 | } else { |
| 42 | t.Fatalscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Fatal().("expected channel to be open") |
| 43 | } |
| 44 | default: |
| 45 | } |
| 46 | |
| 47 | 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, 10, task.Countscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/PercentageTask#Count().(10)) |
| 48 | 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, "example: 100% (10/10)", (<-task.Updatesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/PercentageTask#Updates().()).Sscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/Update#S.) |
| 49 | |
| 50 | if _, ok := <-task.Updatesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/PercentageTask#Updates().(); ok { |
| 51 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Fatalf().("expected channel to be closed") |
| 52 | } |
| 53 | |
| 54 | defer func() { |
| 55 | if err := recover(); err != nil { |
| 56 | t.Fatalscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Fatal().("tasklog: expected *PercentageTask.Complete() to not panic") |
| 57 | } |
| 58 | }() |
| 59 | |
| 60 | task.Completescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/PercentageTask#Complete().() |
| 61 | } |
| 62 | |
| 63 | func TestPercentageTaskCompleteClosesUpdatesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/TestPercentageTaskCompleteClosesUpdates().(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#) { |
| 64 | task := NewPercentageTaskscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/NewPercentageTask().("example", 10) |
| 65 | |
| 66 | select { |
| 67 | case v, ok := <-task.Updatesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/PercentageTask#Updates().(): |
| 68 | if ok { |
| 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, "example: 0% (0/10)", v.Sscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/Update#S.) |
| 70 | } else { |
| 71 | t.Fatalscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Fatal().("expected channel to be open") |
| 72 | } |
| 73 | default: |
| 74 | } |
| 75 | |
| 76 | 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, 7, task.Countscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/PercentageTask#Count().(7)) |
| 77 | 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, "example: 70% (7/10)", (<-task.Updatesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/PercentageTask#Updates().()).Sscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/Update#S.) |
| 78 | |
| 79 | task.Completescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/PercentageTask#Complete().() |
| 80 | |
| 81 | if _, ok := <-task.Updatesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/PercentageTask#Updates().(); ok { |
| 82 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Fatalf().("expected channel to be closed") |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | func TestPercentageTaskIsThrottledscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/TestPercentageTaskIsThrottled().(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 | task := NewPercentageTaskscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/NewPercentageTask().("example", 10) |
| 88 | |
| 89 | throttled := task.Throttledscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/PercentageTask#Throttled().() |
| 90 | |
| 91 | 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, throttled, |
| 92 | "tasklog: expected *PercentageTask to be Throttle()-d") |
| 93 | } |
| 94 | |
| 95 | func TestPercentageTaskPanicsWhenOvercountedscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/TestPercentageTaskPanicsWhenOvercounted().(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#) { |
| 96 | task := NewPercentageTaskscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/NewPercentageTask().("example", 0) |
| 97 | defer func() { |
| 98 | 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, "tasklog: counted too many items", recover()) |
| 99 | }() |
| 100 | |
| 101 | task.Countscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/PercentageTask#Count().(1) |
| 102 | } |