You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: bgrun_test.go
    path of file: ./repos/goatcounter/bgrun
    
    the code of the file until where you have to start completion: package bgrun

import (
	"bytes"
	"context"
	"errors"
	"fmt"
	"os"
	"reflect"
	"sort"
	"strings"
	"testing"
	"time"

	"sync/atomic"
)

var (
	i        atomic.Int32
	testFunc = func(context.Context) error { time.Sleep(50 * time.Millisecond); i.Add(1); return nil }
)

func init() {
	NewTask("test", 1, testFunc)
}

    
func TestWaitFor(t *testing.T) {
	defer reset()

	NewTask("test2", 1, func(ctx context.Context) error {
		select {
		case <-ctx.Done():
		case <-time.After(50 * time.Millisecond):
			t.Error("not cancelled")
		}
		return nil
	})
	MustRunTask("test2")
	MustRunTask("test")

	err := WaitFor(2*time.Millisecond, "")
	if !errors.Is(err, context.DeadlineExceeded) {
		t.Error(err)
	}

	err = WaitFor(50*time.Millisecond, "")
	if err != nil {
		t.Error(err)
	}
}