Adding test coverage for server-mux.go by creating TestListenAndServeTLS(). (#2493)

Editing config.go to add lock on customConfigPath to avoid race condition
when setGlobalConfigPath() and getConfigPath() are called concurrently.
This commit is contained in:
Jesse Lucas
2016-08-19 04:29:50 -04:00
committed by Harshavardhana
parent a8052889fe
commit f2fd8b0265
2 changed files with 153 additions and 10 deletions

View File

@@ -19,20 +19,27 @@ package cmd
import (
"os"
"path/filepath"
"sync"
"github.com/minio/go-homedir"
)
// configPath for custom config path only for testing purposes
var customConfigPath string
var configMu sync.Mutex
// Sets a new config path.
func setGlobalConfigPath(configPath string) {
configMu.Lock()
defer configMu.Unlock()
customConfigPath = configPath
}
// getConfigPath get server config path
func getConfigPath() (string, error) {
configMu.Lock()
defer configMu.Unlock()
if customConfigPath != "" {
return customConfigPath, nil
}