Skip to content

Commit

Permalink
internal/testutils: skip tests if local network isn't supported
Browse files Browse the repository at this point in the history
Happens in the Nix sandbox.
  • Loading branch information
vs49688 committed Nov 5, 2023
1 parent 5fc3a13 commit 47e74d4
Show file tree
Hide file tree
Showing 11 changed files with 933 additions and 4 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require (
github.com/sirupsen/logrus v1.9.3
github.com/stretchr/testify v1.8.4
github.com/urfave/cli/v2 v2.25.7
golang.org/x/net v0.15.0
)

require (
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8=
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
golang.org/x/oauth2 v0.12.0 h1:smVPGxink+n1ZI5pkQa8y6fZT0RW0MgCO5bFpepy4B4=
golang.org/x/oauth2 v0.12.0/go.mod h1:A74bZ3aGXgCY0qaIC9Ahg6Lglin4AMAco8cIv9baba4=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand Down
9 changes: 5 additions & 4 deletions internal/testutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@
package internal

import (
"net"
"testing"

"golang.org/x/net/nettest"

"github.com/emersion/go-imap/backend/memory"
"github.com/emersion/go-imap/server"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -49,10 +50,10 @@ func BuildTestIMAPServer(t *testing.T) (*server.Server, string, *memory.Mailbox)

s.AllowInsecureAuth = true

l, err := net.Listen("tcp", "localhost:0")
assert.NoError(t, err)
l, err := nettest.NewLocalListener("tcp")
if err != nil {
t.FailNow()
t.Logf("%v", err)
t.Skip()
}

go func() { err = s.Serve(l) }()
Expand Down
27 changes: 27 additions & 0 deletions vendor/golang.org/x/net/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions vendor/golang.org/x/net/PATENTS

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 47e74d4

Please sign in to comment.