heal: Print heal command appropriately without export path. (#3208)

Fixes #3204
This commit is contained in:
Harshavardhana
2016-11-09 10:50:14 -08:00
committed by GitHub
parent ea579f5b69
commit 3e67bfcc88
5 changed files with 96 additions and 17 deletions
+51 -1
View File
@@ -18,9 +18,59 @@ package cmd
import (
"net/url"
"reflect"
"testing"
)
// Tests and validates the output for heal endpoint.
func TestGetHealEndpoint(t *testing.T) {
// Test for a SSL scheme.
tls := true
hURL := getHealEndpoint(tls, &url.URL{
Scheme: "http",
Host: "localhost:9000",
})
sHURL := &url.URL{
Scheme: "https",
Host: "localhost:9000",
}
if !reflect.DeepEqual(hURL, sHURL) {
t.Fatalf("Expected %#v, but got %#v", sHURL, hURL)
}
// Test a non-TLS scheme.
tls = false
hURL = getHealEndpoint(tls, &url.URL{
Scheme: "https",
Host: "localhost:9000",
})
sHURL = &url.URL{
Scheme: "http",
Host: "localhost:9000",
}
if !reflect.DeepEqual(hURL, sHURL) {
t.Fatalf("Expected %#v, but got %#v", sHURL, hURL)
}
// FIXME(GLOBAL): purposefully Host is left empty because
// we need to bring in safe handling on global values
// add a proper test case here once that happens.
/*
tls = false
hURL = getHealEndpoint(tls, &url.URL{
Path: "/export",
})
sHURL = &url.URL{
Scheme: "http",
Host: "",
}
globalMinioAddr = ""
if !reflect.DeepEqual(hURL, sHURL) {
t.Fatalf("Expected %#v, but got %#v", sHURL, hURL)
}
*/
}
// Tests heal message to be correct and properly formatted.
func TestHealMsg(t *testing.T) {
rootPath, err := newTestConfig("us-east-1")
@@ -69,7 +119,7 @@ func TestHealMsg(t *testing.T) {
},
}
for i, testCase := range testCases {
msg := getHealMsg(testCase.endPoints[0].String(), testCase.storageDisks)
msg := getHealMsg(testCase.endPoints, testCase.storageDisks)
if msg == "" {
t.Fatalf("Test: %d Unable to get heal message.", i+1)
}