| 1 | package block_contest_test |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | "time" |
| 6 | |
| 7 | . "github.com/onsi/ginkgo/v2" |
| 8 | . "github.com/onsi/gomega" |
| 9 | |
| 10 | "github.com/onsi/ginkgo/v2/integration/_fixtures/profile_fixture/block_contest" |
| 11 | ) |
| 12 | |
| 13 | func TestBlockContest(t *testing.T) { |
| 14 | RegisterFailHandler(Fail) |
| 15 | RunSpecs(t, "BlockContest Suite") |
| 16 | } |
| 17 | |
| 18 | var _ = Describe("quick channel reads", func() { |
| 19 | for i := 0; i < 10; i++ { |
| 20 | It("reads a channel quickly", func() { |
| 21 | c := make(chan bool) |
| 22 | go func() { |
| 23 | block_contest.ReadTheChannel(c) |
| 24 | }() |
| 25 | time.Sleep(5 * time.Millisecond) |
| 26 | c <- true |
| 27 | }) |
| 28 | } |
| 29 | }) |
| 30 | |
| 31 | var _ = Describe("slow channel reads", func() { |
| 32 | It("gets stuck for a bit", func() { |
| 33 | c := make(chan bool) |
| 34 | go func() { |
| 35 | block_contest.SlowReadTheChannel(c) |
| 36 | }() |
| 37 | time.Sleep(500 * time.Millisecond) |
| 38 | c <- true |
| 39 | }) |
| 40 | }) |