Skip to content

Commit

Permalink
chore: remove dependency on /x/sync
Browse files Browse the repository at this point in the history
For a public repo it's better with one less dependency than a slightly
simpler test in this case.
  • Loading branch information
odsod committed Dec 29, 2020
1 parent 08fe9a3 commit 2927d06
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ go 1.14

require (
golang.org/x/net v0.0.0-20201224014010-6772e930b67b
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a
gotest.tools/v3 v3.0.3
)
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ golang.org/x/net v0.0.0-20201224014010-6772e930b67b h1:iFwSg7t5GZmB/Q5TjiEAsdoLD
golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a h1:DcqTD9SDLc+1P/r1EmRBwnVsrOwW+kk2vWf9n+1sGhs=
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 h1:nxC68pudNYkKU6jWhgrqdreuFiOQWj1Fs7T3VrH4Pjw=
Expand Down
16 changes: 10 additions & 6 deletions receiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package vlp16
import (
"context"
"net"
"sync"
"testing"
"time"

"golang.org/x/net/nettest"
"golang.org/x/sync/errgroup"
"gotest.tools/v3/assert"
)

Expand All @@ -18,16 +18,20 @@ func TestClient_Receive(t *testing.T) {
addr := getFreeAddress(t)
rx, err := ListenUDP(ctx, addr)
assert.NilError(t, err)
var g errgroup.Group
g.Go(func() error {
return rx.Receive(ctx)
})
var g sync.WaitGroup
g.Add(1)
go func() {
defer g.Done()
if err := rx.Receive(ctx); err != nil {
t.Error(err)
}
}()
conn, err := net.Dial("udp4", addr)
assert.NilError(t, err)
_, err = conn.Write(exampleRawPacket(t)[:])
assert.NilError(t, err)
assert.NilError(t, conn.Close())
assert.NilError(t, g.Wait())
g.Wait()
assert.DeepEqual(t, exampleRawPacket(t), rx.RawPacket())
assert.DeepEqual(t, examplePacket(), rx.Packet())
}
Expand Down

0 comments on commit 2927d06

Please sign in to comment.