Simplify gateway backend registration (#5111)

This commit is contained in:
Timon Wong
2017-10-27 17:07:46 -05:00
committed by Dee Koder
parent 7195ac7f14
commit 6400f506da
9 changed files with 357 additions and 299 deletions

View File

@@ -19,8 +19,31 @@ package cmd
import (
"strings"
"testing"
"github.com/minio/cli"
)
// Test RegisterGatewayCommand
func TestRegisterGatewayCommand(t *testing.T) {
var err error
cmd := cli.Command{Name: "test"}
err = RegisterGatewayCommand(cmd)
if err != nil {
t.Errorf("RegisterGatewayCommand got unexpected error: %s", err)
}
// Should returns 'duplicated' error
err = RegisterGatewayCommand(cmd)
if err == nil {
t.Errorf("RegisterGatewayCommand twice with same name should return error")
} else {
if err.Error() != "duplicate gateway: test" {
t.Errorf("RegisterGatewayCommand got unexpected error: %s", err)
}
}
}
// Test parseGatewayEndpoint
func TestParseGatewayEndpoint(t *testing.T) {
testCases := []struct {