Adding return error value to checkPortAvailability to enable testing of function. Adding checkport_test.go to test checkPortAvailability. Updated server-main.go to use error value from checkPortAvailability and calls fatalIf if an error is returned. (#2322)

This commit is contained in:
Jesse Lucas
2016-07-29 17:05:31 -04:00
committed by Harshavardhana
parent cf9ba7b88f
commit 851d05161a
3 changed files with 76 additions and 12 deletions

View File

@@ -246,7 +246,9 @@ func serverMain(c *cli.Context) {
serverAddress := c.String("address")
// Check if requested port is available.
checkPortAvailability(getPort(serverAddress))
port := getPort(serverAddress)
err := checkPortAvailability(port)
fatalIf(err, "Port unavailable %d", port)
// Disks to be ignored in server init, to skip format healing.
ignoredDisks := strings.Split(c.String("ignore-disks"), ",")
@@ -268,7 +270,6 @@ func serverMain(c *cli.Context) {
printStartupMessage(endPoints)
// Start server.
var err error
// Configure TLS if certs are available.
if tls {
err = apiServer.ListenAndServeTLS(mustGetCertFile(), mustGetKeyFile())