mirror of
				https://github.com/elyby/chrly.git
				synced 2025-05-31 14:11:51 +05:30 
			
		
		
		
	Fix FullBus test
This commit is contained in:
		| @@ -2,6 +2,7 @@ package mojangtextures | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"fmt" | ||||
| 	"strconv" | ||||
| 	"sync" | ||||
| 	"testing" | ||||
| @@ -328,7 +329,6 @@ func TestPeriodicStrategy(t *testing.T) { | ||||
| 	}) | ||||
| } | ||||
|  | ||||
|  | ||||
| func TestFullBusStrategy(t *testing.T) { | ||||
| 	t.Run("should provide iteration immediately when the batch size exceeded", func(t *testing.T) { | ||||
| 		jobs := make([]*job, 10) | ||||
| @@ -373,18 +373,19 @@ func TestFullBusStrategy(t *testing.T) { | ||||
| 		ctx, cancel := context.WithCancel(context.Background()) | ||||
| 		ch := strategy.GetJobs(ctx) | ||||
|  | ||||
| 		var startedAt time.Time | ||||
| 		done := make(chan struct{}) | ||||
| 		go func() { | ||||
| 			defer close(done) | ||||
| 			startedAt := time.Now() | ||||
| 			iteration := <-ch | ||||
| 			duration := time.Now().Sub(startedAt) | ||||
| 			require.True(t, duration >= d) | ||||
| 			require.True(t, duration >= d, fmt.Sprintf("has %d, expected %d", duration, d)) | ||||
| 			require.True(t, duration < d*2) | ||||
| 			require.Equal(t, jobs, iteration.Jobs) | ||||
| 			require.Equal(t, 0, iteration.Queue) | ||||
| 		}() | ||||
|  | ||||
| 		startedAt = time.Now() | ||||
| 		for _, j := range jobs { | ||||
| 			strategy.Queue(j) | ||||
| 		} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user