|
@@ -10,11 +10,11 @@ import (
|
|
|
|
|
|
func TestTransfer(t *testing.T) {
|
|
func TestTransfer(t *testing.T) {
|
|
makeXferFunc := func(id string) DoFunc {
|
|
makeXferFunc := func(id string) DoFunc {
|
|
- return func(progressChan chan<- progress.Progress, start <-chan struct{}, inactive chan<- struct{}) Transfer {
|
|
|
|
|
|
+ return func(progressChan chan<- progress.Progress, start <-chan struct{}, _ chan<- struct{}) Transfer {
|
|
select {
|
|
select {
|
|
case <-start:
|
|
case <-start:
|
|
default:
|
|
default:
|
|
- t.Fatalf("transfer function not started even though concurrency limit not reached")
|
|
|
|
|
|
+ t.Errorf("%s: transfer function not started even though concurrency limit not reached", id)
|
|
}
|
|
}
|
|
|
|
|
|
xfer := NewTransfer()
|
|
xfer := NewTransfer()
|
|
@@ -38,7 +38,7 @@ func TestTransfer(t *testing.T) {
|
|
for p := range progressChan {
|
|
for p := range progressChan {
|
|
val, present := receivedProgress[p.ID]
|
|
val, present := receivedProgress[p.ID]
|
|
if present && p.Current <= val {
|
|
if present && p.Current <= val {
|
|
- t.Fatalf("got unexpected progress value: %d (expected %d)", p.Current, val+1)
|
|
|
|
|
|
+ t.Errorf("%s: got unexpected progress value: %d (expected <= %d)", p.ID, p.Current, val)
|
|
}
|
|
}
|
|
receivedProgress[p.ID] = p.Current
|
|
receivedProgress[p.ID] = p.Current
|
|
}
|
|
}
|
|
@@ -72,13 +72,13 @@ func TestConcurrencyLimit(t *testing.T) {
|
|
var runningJobs int32
|
|
var runningJobs int32
|
|
|
|
|
|
makeXferFunc := func(id string) DoFunc {
|
|
makeXferFunc := func(id string) DoFunc {
|
|
- return func(progressChan chan<- progress.Progress, start <-chan struct{}, inactive chan<- struct{}) Transfer {
|
|
|
|
|
|
+ return func(progressChan chan<- progress.Progress, start <-chan struct{}, _ chan<- struct{}) Transfer {
|
|
xfer := NewTransfer()
|
|
xfer := NewTransfer()
|
|
go func() {
|
|
go func() {
|
|
<-start
|
|
<-start
|
|
totalJobs := atomic.AddInt32(&runningJobs, 1)
|
|
totalJobs := atomic.AddInt32(&runningJobs, 1)
|
|
if int(totalJobs) > concurrencyLimit {
|
|
if int(totalJobs) > concurrencyLimit {
|
|
- t.Fatalf("too many jobs running")
|
|
|
|
|
|
+ t.Errorf("%s: too many jobs running (%d > %d)", id, totalJobs, concurrencyLimit)
|
|
}
|
|
}
|
|
for i := 0; i <= 10; i++ {
|
|
for i := 0; i <= 10; i++ {
|
|
progressChan <- progress.Progress{ID: id, Action: "testing", Current: int64(i), Total: 10}
|
|
progressChan <- progress.Progress{ID: id, Action: "testing", Current: int64(i), Total: 10}
|
|
@@ -137,7 +137,7 @@ func TestInactiveJobs(t *testing.T) {
|
|
<-start
|
|
<-start
|
|
totalJobs := atomic.AddInt32(&runningJobs, 1)
|
|
totalJobs := atomic.AddInt32(&runningJobs, 1)
|
|
if int(totalJobs) > concurrencyLimit {
|
|
if int(totalJobs) > concurrencyLimit {
|
|
- t.Fatalf("too many jobs running")
|
|
|
|
|
|
+ t.Errorf("%s: too many jobs running (%d > %d)", id, totalJobs, concurrencyLimit)
|
|
}
|
|
}
|
|
for i := 0; i <= 10; i++ {
|
|
for i := 0; i <= 10; i++ {
|
|
progressChan <- progress.Progress{ID: id, Action: "testing", Current: int64(i), Total: 10}
|
|
progressChan <- progress.Progress{ID: id, Action: "testing", Current: int64(i), Total: 10}
|
|
@@ -191,7 +191,7 @@ func TestWatchRelease(t *testing.T) {
|
|
ready := make(chan struct{})
|
|
ready := make(chan struct{})
|
|
|
|
|
|
makeXferFunc := func(id string) DoFunc {
|
|
makeXferFunc := func(id string) DoFunc {
|
|
- return func(progressChan chan<- progress.Progress, start <-chan struct{}, inactive chan<- struct{}) Transfer {
|
|
|
|
|
|
+ return func(progressChan chan<- progress.Progress, start <-chan struct{}, _ chan<- struct{}) Transfer {
|
|
xfer := NewTransfer()
|
|
xfer := NewTransfer()
|
|
go func() {
|
|
go func() {
|
|
defer func() {
|
|
defer func() {
|
|
@@ -280,7 +280,7 @@ func TestWatchRelease(t *testing.T) {
|
|
|
|
|
|
func TestWatchFinishedTransfer(t *testing.T) {
|
|
func TestWatchFinishedTransfer(t *testing.T) {
|
|
makeXferFunc := func(id string) DoFunc {
|
|
makeXferFunc := func(id string) DoFunc {
|
|
- return func(progressChan chan<- progress.Progress, start <-chan struct{}, inactive chan<- struct{}) Transfer {
|
|
|
|
|
|
+ return func(progressChan chan<- progress.Progress, _ <-chan struct{}, _ chan<- struct{}) Transfer {
|
|
xfer := NewTransfer()
|
|
xfer := NewTransfer()
|
|
go func() {
|
|
go func() {
|
|
// Finish immediately
|
|
// Finish immediately
|
|
@@ -322,7 +322,7 @@ func TestDuplicateTransfer(t *testing.T) {
|
|
var xferFuncCalls int32
|
|
var xferFuncCalls int32
|
|
|
|
|
|
makeXferFunc := func(id string) DoFunc {
|
|
makeXferFunc := func(id string) DoFunc {
|
|
- return func(progressChan chan<- progress.Progress, start <-chan struct{}, inactive chan<- struct{}) Transfer {
|
|
|
|
|
|
+ return func(progressChan chan<- progress.Progress, _ <-chan struct{}, _ chan<- struct{}) Transfer {
|
|
atomic.AddInt32(&xferFuncCalls, 1)
|
|
atomic.AddInt32(&xferFuncCalls, 1)
|
|
xfer := NewTransfer()
|
|
xfer := NewTransfer()
|
|
go func() {
|
|
go func() {
|