-
Notifications
You must be signed in to change notification settings - Fork 243
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update harness and add tests to validate mail server functionality
- Loading branch information
1 parent
c9f3447
commit f15b06f
Showing
4 changed files
with
308 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package harness | ||
|
||
import ( | ||
"net" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestFindOpenPorts(t *testing.T) { | ||
// This test is more of a sanity check than anything else. | ||
// | ||
// Finding an open port is dependent on the system's network state, so it's | ||
// difficult to write a deterministic test for it. This test is just to | ||
// ensure that the function doesn't panic and returns a valid port. | ||
ports, err := findOpenPorts(1) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
if !strings.Contains(ports[0], ":") { | ||
t.Fatalf("expected port to contain colon, got %s", ports[0]) | ||
} | ||
|
||
// Ensure the port is actually open | ||
l, err := net.Listen("tcp", ports[0]) | ||
require.NoError(t, err) | ||
defer l.Close() | ||
} |
Oops, something went wrong.