github.com/demonoid81/moby@v0.0.0-20200517203328-62dd8e17c460/libcontainerd/queue/queue_test.go (about) 1 package queue // import "github.com/demonoid81/moby/libcontainerd/queue" 2 3 import ( 4 "testing" 5 "time" 6 7 "gotest.tools/v3/assert" 8 ) 9 10 func TestSerialization(t *testing.T) { 11 var ( 12 q Queue 13 serialization = 1 14 ) 15 16 q.Append("aaa", func() { 17 // simulate a long time task 18 time.Sleep(10 * time.Millisecond) 19 assert.Equal(t, serialization, 1) 20 serialization = 2 21 }) 22 q.Append("aaa", func() { 23 assert.Equal(t, serialization, 2) 24 serialization = 3 25 }) 26 q.Append("aaa", func() { 27 assert.Equal(t, serialization, 3) 28 serialization = 4 29 }) 30 time.Sleep(20 * time.Millisecond) 31 }