github.com/MeteorsLiu/simpleMQ@v1.0.3/queue/simple_test.go (about)

     1  package queue
     2  
     3  import "testing"
     4  
     5  func TestSimpleCopy(t *testing.T) {
     6  	q := NewSimpleQueue()
     7  	q.Publish(NewTask(func() error {
     8  		return nil
     9  	}))
    10  	q.Publish(NewTask(func() error {
    11  		return nil
    12  	}))
    13  	q.Publish(NewTask(func() error {
    14  		return nil
    15  	}))
    16  	q.Publish(NewTask(func() error {
    17  		return nil
    18  	}))
    19  	t.Log(q.Copy())
    20  	q.Pop()
    21  	t.Log(q.Copy())
    22  }
    23  
    24  func TestTask(t *testing.T) {
    25  	task := NewTask(func() error {
    26  		return nil
    27  	})
    28  	task.TaskContext().Store("t", 123)
    29  	t.Log(task.TaskContext().Load("t"))
    30  }