Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
petar committed Jul 20, 2021
1 parent c50eae7 commit 24f8245
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions peertracker/peertracker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import (
"github.com/ipfs/go-peertaskqueue/testutil"
)

const testMaxActiveWorkPerPeer = 100

func TestEmpty(t *testing.T) {
partner := testutil.GeneratePeers(1)[0]
tracker := New(partner, &DefaultTaskMerger{})
tracker := New(partner, &DefaultTaskMerger{}, testMaxActiveWorkPerPeer)

tasks, _ := tracker.PopTasks(100)
if len(tasks) != 0 {
Expand All @@ -19,7 +21,7 @@ func TestEmpty(t *testing.T) {

func TestPushPop(t *testing.T) {
partner := testutil.GeneratePeers(1)[0]
tracker := New(partner, &DefaultTaskMerger{})
tracker := New(partner, &DefaultTaskMerger{}, testMaxActiveWorkPerPeer)

tasks := []peertask.Task{
{
Expand All @@ -40,7 +42,7 @@ func TestPushPop(t *testing.T) {

func TestPopNegativeOrZeroSize(t *testing.T) {
partner := testutil.GeneratePeers(1)[0]
tracker := New(partner, &DefaultTaskMerger{})
tracker := New(partner, &DefaultTaskMerger{}, testMaxActiveWorkPerPeer)

tasks := []peertask.Task{
{
Expand All @@ -62,7 +64,7 @@ func TestPopNegativeOrZeroSize(t *testing.T) {

func TestPushPopSizeAndOrder(t *testing.T) {
partner := testutil.GeneratePeers(1)[0]
tracker := New(partner, &DefaultTaskMerger{})
tracker := New(partner, &DefaultTaskMerger{}, testMaxActiveWorkPerPeer)

tasks := []peertask.Task{
{
Expand Down Expand Up @@ -116,7 +118,7 @@ func TestPushPopSizeAndOrder(t *testing.T) {

func TestPopFirstItemAlways(t *testing.T) {
partner := testutil.GeneratePeers(1)[0]
tracker := New(partner, &DefaultTaskMerger{})
tracker := New(partner, &DefaultTaskMerger{}, testMaxActiveWorkPerPeer)

tasks := []peertask.Task{
{
Expand Down Expand Up @@ -147,7 +149,7 @@ func TestPopFirstItemAlways(t *testing.T) {

func TestPopItemsToCoverTargetWork(t *testing.T) {
partner := testutil.GeneratePeers(1)[0]
tracker := New(partner, &DefaultTaskMerger{})
tracker := New(partner, &DefaultTaskMerger{}, testMaxActiveWorkPerPeer)

tasks := []peertask.Task{
{
Expand Down Expand Up @@ -183,7 +185,7 @@ func TestPopItemsToCoverTargetWork(t *testing.T) {

func TestRemove(t *testing.T) {
partner := testutil.GeneratePeers(1)[0]
tracker := New(partner, &DefaultTaskMerger{})
tracker := New(partner, &DefaultTaskMerger{}, testMaxActiveWorkPerPeer)

tasks := []peertask.Task{
{
Expand Down Expand Up @@ -215,7 +217,7 @@ func TestRemove(t *testing.T) {

func TestRemoveMulti(t *testing.T) {
partner := testutil.GeneratePeers(1)[0]
tracker := New(partner, &DefaultTaskMerger{})
tracker := New(partner, &DefaultTaskMerger{}, testMaxActiveWorkPerPeer)

tasks := []peertask.Task{
{
Expand Down Expand Up @@ -247,7 +249,7 @@ func TestRemoveMulti(t *testing.T) {

func TestTaskDone(t *testing.T) {
partner := testutil.GeneratePeers(1)[0]
tracker := New(partner, &DefaultTaskMerger{})
tracker := New(partner, &DefaultTaskMerger{}, testMaxActiveWorkPerPeer)

tasks := []peertask.Task{
{
Expand Down Expand Up @@ -299,7 +301,7 @@ func (*permissiveTaskMerger) Merge(task peertask.Task, existing *peertask.Task)

func TestReplaceTaskPermissive(t *testing.T) {
partner := testutil.GeneratePeers(1)[0]
tracker := New(partner, &permissiveTaskMerger{})
tracker := New(partner, &permissiveTaskMerger{}, testMaxActiveWorkPerPeer)

tasks := []peertask.Task{
{
Expand Down Expand Up @@ -338,7 +340,7 @@ func TestReplaceTaskPermissive(t *testing.T) {

func TestReplaceTaskSize(t *testing.T) {
partner := testutil.GeneratePeers(1)[0]
tracker := New(partner, &permissiveTaskMerger{})
tracker := New(partner, &permissiveTaskMerger{}, testMaxActiveWorkPerPeer)

tasks := []peertask.Task{
{
Expand Down Expand Up @@ -391,7 +393,7 @@ func TestReplaceTaskSize(t *testing.T) {

func TestReplaceActiveTask(t *testing.T) {
partner := testutil.GeneratePeers(1)[0]
tracker := New(partner, &permissiveTaskMerger{})
tracker := New(partner, &permissiveTaskMerger{}, testMaxActiveWorkPerPeer)

tasks := []peertask.Task{
{
Expand Down Expand Up @@ -430,7 +432,7 @@ func TestReplaceActiveTask(t *testing.T) {

func TestReplaceActiveTaskNonPermissive(t *testing.T) {
partner := testutil.GeneratePeers(1)[0]
tracker := New(partner, &DefaultTaskMerger{})
tracker := New(partner, &DefaultTaskMerger{}, testMaxActiveWorkPerPeer)

tasks := []peertask.Task{
{
Expand Down Expand Up @@ -468,7 +470,7 @@ func TestReplaceActiveTaskNonPermissive(t *testing.T) {

func TestReplaceTaskThatIsActiveAndPending(t *testing.T) {
partner := testutil.GeneratePeers(1)[0]
tracker := New(partner, &permissiveTaskMerger{})
tracker := New(partner, &permissiveTaskMerger{}, testMaxActiveWorkPerPeer)

tasks := []peertask.Task{
{
Expand Down Expand Up @@ -519,7 +521,7 @@ func TestReplaceTaskThatIsActiveAndPending(t *testing.T) {

func TestRemoveActive(t *testing.T) {
partner := testutil.GeneratePeers(1)[0]
tracker := New(partner, &permissiveTaskMerger{})
tracker := New(partner, &permissiveTaskMerger{}, testMaxActiveWorkPerPeer)

tasks := []peertask.Task{
{
Expand Down

0 comments on commit 24f8245

Please sign in to comment.