You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by cs...@apache.org on 2018/01/27 19:55:57 UTC
[incubator-openwhisk-cli] 02/03: Fail Travis when Go formatting
errors exist
This is an automated email from the ASF dual-hosted git repository.
csantanapr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-cli.git
commit f02d6a7fdc287b6137617388a7a41328a5757c60
Author: dubeejw <jw...@us.ibm.com>
AuthorDate: Sat Jan 27 10:46:20 2018 -0500
Fail Travis when Go formatting errors exist
---
.travis.yml | 3 +
build.gradle | 4 +
commands/api.go | 14 +-
tests/src/integration/command_test.go | 942 ++++++++++++++--------------
tests/src/integration/common/utils.go | 132 ++--
tests/src/integration/common/wsk.go | 66 +-
tests/src/integration/integration_test.go | 994 +++++++++++++++---------------
wski18n/detection.go | 24 +-
wski18n/i18n.go | 152 ++---
wski18n/i18n_resources.go | 510 +++++++--------
10 files changed, 1424 insertions(+), 1417 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 2620fc8..42934f0 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -28,6 +28,9 @@ install:
- pip install --upgrade pip setuptools
before_script:
+ - cd $TRAVIS_BUILD_DIR
+ - GO_FILES=$(find . -iname '*.go' -type f | grep -v /vendor/)
+ - test -z "$(gofmt -s -l $(echo $GO_FILES))"
- cd $TRAVIS_BUILD_DIR/..
- git clone https://github.com/apache/incubator-openwhisk-utilities.git
- git clone https://github.com/apache/incubator-openwhisk.git
diff --git a/build.gradle b/build.gradle
index ba6171d..00c0cd4 100644
--- a/build.gradle
+++ b/build.gradle
@@ -193,6 +193,10 @@ goBuild {
golang.packagePath ] as List<String>)
}
+gofmt {
+ gofmt "-s -w ."
+}
+
task compile(type: Copy, dependsOn: goBuild) {
destinationDir = file('./build')
from("./build/${rootProject.localPlatform.goOs}-${rootProject.localPlatform.goArch}")
diff --git a/commands/api.go b/commands/api.go
index 50b8d89..4134683 100644
--- a/commands/api.go
+++ b/commands/api.go
@@ -99,11 +99,11 @@ func isValidRelpath(relpath string) (error, bool) {
func getManagedUrl(api *whisk.RetApi, relpath string, operation string) (url string) {
baseUrl := strings.TrimSuffix(api.BaseUrl, "/")
whisk.Debug(whisk.DbgInfo, "getManagedUrl: baseUrl = '%s', relpath = '%s', operation = '%s'\n", baseUrl, relpath, operation)
- for path, _ := range api.Swagger.Paths {
+ for path := range api.Swagger.Paths {
whisk.Debug(whisk.DbgInfo, "getManagedUrl: comparing api relpath: '%s'\n", path)
if path == relpath {
whisk.Debug(whisk.DbgInfo, "getManagedUrl: relpath matches '%s'\n", relpath)
- for op, _ := range api.Swagger.Paths[path] {
+ for op := range api.Swagger.Paths[path] {
whisk.Debug(whisk.DbgInfo, "getManagedUrl: comparing operation: '%s'\n", op)
if strings.ToLower(op) == strings.ToLower(operation) {
whisk.Debug(whisk.DbgInfo, "getManagedUrl: operation matches: '%s'\n", operation)
@@ -205,7 +205,7 @@ var apiCreateCmd = &cobra.Command{
} else {
whisk.Debug(whisk.DbgInfo, "Processing swagger based create API response\n")
baseUrl := retApi.BaseUrl
- for path, _ := range retApi.Swagger.Paths {
+ for path := range retApi.Swagger.Paths {
managedUrl := strings.TrimSuffix(baseUrl, "/") + path
whisk.Debug(whisk.DbgInfo, "Managed path: '%s'\n", managedUrl)
for op, opv := range retApi.Swagger.Paths[path] {
@@ -573,7 +573,7 @@ func genFilteredList(resultApi *whisk.RetApi, apiPath string, apiVerb string) []
apiName := resultApi.Swagger.Info.Title
basePath := resultApi.Swagger.BasePath
if resultApi.Swagger != nil && resultApi.Swagger.Paths != nil {
- for path, _ := range resultApi.Swagger.Paths {
+ for path := range resultApi.Swagger.Paths {
whisk.Debug(whisk.DbgInfo, "genFilteredApi: comparing api relpath: '%s'\n", path)
if len(apiPath) == 0 || path == apiPath {
whisk.Debug(whisk.DbgInfo, "genFilteredList: relpath matches\n")
@@ -611,7 +611,7 @@ func genFilteredRow(resultApi *whisk.RetApi, apiPath string, apiVerb string, max
apiName := resultApi.Swagger.Info.Title
basePath := resultApi.Swagger.BasePath
if resultApi.Swagger != nil && resultApi.Swagger.Paths != nil {
- for path, _ := range resultApi.Swagger.Paths {
+ for path := range resultApi.Swagger.Paths {
whisk.Debug(whisk.DbgInfo, "genFilteredRow: comparing api relpath: '%s'\n", path)
if len(apiPath) == 0 || path == apiPath {
whisk.Debug(whisk.DbgInfo, "genFilteredRow: relpath matches\n")
@@ -674,7 +674,7 @@ func getLargestActionNameSize(retApiArray *whisk.RetApiArray, apiPath string, ap
for i := 0; i < len(retApiArray.Apis); i++ {
var resultApi = retApiArray.Apis[i].ApiValue
if resultApi.Swagger != nil && resultApi.Swagger.Paths != nil {
- for path, _ := range resultApi.Swagger.Paths {
+ for path := range resultApi.Swagger.Paths {
whisk.Debug(whisk.DbgInfo, "getLargestActionNameSize: comparing api relpath: '%s'\n", path)
if len(apiPath) == 0 || path == apiPath {
whisk.Debug(whisk.DbgInfo, "getLargestActionNameSize: relpath matches\n")
@@ -708,7 +708,7 @@ func getLargestApiNameSize(retApiArray *whisk.RetApiArray, apiPath string, apiVe
var resultApi = retApiArray.Apis[i].ApiValue
apiName := resultApi.Swagger.Info.Title
if resultApi.Swagger != nil && resultApi.Swagger.Paths != nil {
- for path, _ := range resultApi.Swagger.Paths {
+ for path := range resultApi.Swagger.Paths {
whisk.Debug(whisk.DbgInfo, "getLargestActionNameSize: comparing api relpath: '%s'\n", path)
if len(apiPath) == 0 || path == apiPath {
whisk.Debug(whisk.DbgInfo, "getLargestActionNameSize: relpath matches\n")
diff --git a/tests/src/integration/command_test.go b/tests/src/integration/command_test.go
index bc08df1..d4808f1 100644
--- a/tests/src/integration/command_test.go
+++ b/tests/src/integration/command_test.go
@@ -20,10 +20,10 @@
package tests
import (
- "testing"
- "os"
- "github.com/stretchr/testify/assert"
- "github.com/apache/incubator-openwhisk-cli/tests/src/integration/common"
+ "github.com/apache/incubator-openwhisk-cli/tests/src/integration/common"
+ "github.com/stretchr/testify/assert"
+ "os"
+ "testing"
)
var wsk *common.Wsk = common.NewWsk()
@@ -42,528 +42,528 @@ var missingFileMsg = "File '" + missingFile + "' is not a valid file or it does
// Test case to check if the binary exits.
func TestWskExist(t *testing.T) {
- assert.True(t, wsk.Exists(), "The binary should exist.")
+ assert.True(t, wsk.Exists(), "The binary should exist.")
}
func TestHelpUsageInfoCommand(t *testing.T) {
- stdout, err := wsk.RunCommand("-h")
- assert.Equal(t, nil, err, "The command -h failed to run.")
- assert.Contains(t, string(stdout), "Usage:", "The output of the command -h does not contain \"Usage\".")
- assert.Contains(t, string(stdout), "Flags:", "The output of the command -h does not contain \"Flags\".")
- assert.Contains(t, string(stdout), "Available Commands:",
- "The output of the command -h does not contain \"Available Commands\".")
- assert.Contains(t, string(stdout), "--help", "The output of the command -h does not contain \"--help\".")
+ stdout, err := wsk.RunCommand("-h")
+ assert.Equal(t, nil, err, "The command -h failed to run.")
+ assert.Contains(t, string(stdout), "Usage:", "The output of the command -h does not contain \"Usage\".")
+ assert.Contains(t, string(stdout), "Flags:", "The output of the command -h does not contain \"Flags\".")
+ assert.Contains(t, string(stdout), "Available Commands:",
+ "The output of the command -h does not contain \"Available Commands\".")
+ assert.Contains(t, string(stdout), "--help", "The output of the command -h does not contain \"--help\".")
}
func TestHelpUsageInfoCommandLanguage(t *testing.T) {
- os.Setenv("LANG", "de_DE")
- assert.Equal(t, "de_DE", os.Getenv("LANG"), "The environment variable LANG has not been set to de_DE.")
- TestHelpUsageInfoCommand(t)
+ os.Setenv("LANG", "de_DE")
+ assert.Equal(t, "de_DE", os.Getenv("LANG"), "The environment variable LANG has not been set to de_DE.")
+ TestHelpUsageInfoCommand(t)
}
func TestShowCLIBuildVersion(t *testing.T) {
- stdout, err := wsk.RunCommand("property", "get", "--cliversion")
- assert.Equal(t, nil, err, "The command property get --cliversion failed to run.")
- output := common.RemoveRedundentSpaces(string(stdout))
- assert.NotContains(t, output, "whisk CLI version not set",
- "The output of the command property get --cliversion contains \"whisk CLI version not set\".")
- assert.Contains(t, output, "whisk CLI version",
- "The output of the command property get --cliversion does not contain \"whisk CLI version\".")
+ stdout, err := wsk.RunCommand("property", "get", "--cliversion")
+ assert.Equal(t, nil, err, "The command property get --cliversion failed to run.")
+ output := common.RemoveRedundentSpaces(string(stdout))
+ assert.NotContains(t, output, "whisk CLI version not set",
+ "The output of the command property get --cliversion contains \"whisk CLI version not set\".")
+ assert.Contains(t, output, "whisk CLI version",
+ "The output of the command property get --cliversion does not contain \"whisk CLI version\".")
}
func TestShowAPIVersion(t *testing.T) {
- stdout, err := wsk.RunCommand("property", "get", "--apiversion")
- assert.Equal(t, nil, err, "The command property get --apiversion failed to run.")
- assert.Contains(t, string(stdout), "whisk API version",
- "The output of the command property get --apiversion does not contain \"whisk API version\".")
+ stdout, err := wsk.RunCommand("property", "get", "--apiversion")
+ assert.Equal(t, nil, err, "The command property get --apiversion failed to run.")
+ assert.Contains(t, string(stdout), "whisk API version",
+ "The output of the command property get --apiversion does not contain \"whisk API version\".")
}
// Test case to verify the default namespace _.
func TestDefaultNamespace(t *testing.T) {
- common.CreateFile(tmpProp)
- common.WriteFile(tmpProp, []string{"NAMESPACE="})
+ common.CreateFile(tmpProp)
+ common.WriteFile(tmpProp, []string{"NAMESPACE="})
- os.Setenv("WSK_CONFIG_FILE", tmpProp)
- assert.Equal(t, os.Getenv("WSK_CONFIG_FILE"), tmpProp, "The environment variable WSK_CONFIG_FILE has not been set.")
+ os.Setenv("WSK_CONFIG_FILE", tmpProp)
+ assert.Equal(t, os.Getenv("WSK_CONFIG_FILE"), tmpProp, "The environment variable WSK_CONFIG_FILE has not been set.")
- stdout, err := wsk.RunCommand("property", "get", "-i", "--namespace")
- assert.Equal(t, nil, err, "The command property get -i --namespace failed to run.")
- assert.Contains(t, common.RemoveRedundentSpaces(string(stdout)), "whisk namespace _",
- "The output of the command does not contain \"whisk namespace _\".")
- common.DeleteFile(tmpProp)
+ stdout, err := wsk.RunCommand("property", "get", "-i", "--namespace")
+ assert.Equal(t, nil, err, "The command property get -i --namespace failed to run.")
+ assert.Contains(t, common.RemoveRedundentSpaces(string(stdout)), "whisk namespace _",
+ "The output of the command does not contain \"whisk namespace _\".")
+ common.DeleteFile(tmpProp)
}
// Test case to validate default property values.
func TestValidateDefaultProperties(t *testing.T) {
- common.CreateFile(tmpProp)
-
- os.Setenv("WSK_CONFIG_FILE", tmpProp)
- assert.Equal(t, os.Getenv("WSK_CONFIG_FILE"), tmpProp, "The environment variable WSK_CONFIG_FILE has not been set.")
-
- stdout, err := wsk.RunCommand("property", "unset", "--auth", "--apihost", "--apiversion", "--namespace")
- assert.Equal(t, nil, err, "The command property unset failed to run.")
- outputString := string(stdout)
- assert.Contains(t, outputString, "ok: whisk auth unset",
- "The output of the command does not contain \"ok: whisk auth unset\".")
- assert.Contains(t, outputString, "ok: whisk API host unset",
- "The output of the command does not contain \"ok: whisk API host unset\".")
- assert.Contains(t, outputString, "ok: whisk API version unset",
- "The output of the command does not contain \"ok: whisk API version unset\".")
- assert.Contains(t, outputString, "ok: whisk namespace unset",
- "The output of the command does not contain \"ok: whisk namespace unset\".")
-
- stdout, err = wsk.RunCommand("property", "get", "--auth")
- assert.Equal(t, nil, err, "The command property get --auth failed to run.")
- assert.Equal(t, "whisk auth", common.RemoveRedundentSpaces(string(stdout)),
- "The output of the command does not equal to \"whisk auth\".")
-
- stdout, err = wsk.RunCommand("property", "get", "--apihost")
- assert.Equal(t, nil, err, "The command property get --apihost failed to run.")
- assert.Equal(t, "whisk API host", common.RemoveRedundentSpaces(string(stdout)),
- "The output of the command does not equal to \"whisk API host\".")
-
- stdout, err = wsk.RunCommand("property", "get", "--namespace")
- assert.Equal(t, nil, err, "The command property get --namespace failed to run.")
- assert.Equal(t, "whisk namespace _", common.RemoveRedundentSpaces(string(stdout)),
- "The output of the command does not equal to \"whisk namespace _\".")
-
- common.DeleteFile(tmpProp)
+ common.CreateFile(tmpProp)
+
+ os.Setenv("WSK_CONFIG_FILE", tmpProp)
+ assert.Equal(t, os.Getenv("WSK_CONFIG_FILE"), tmpProp, "The environment variable WSK_CONFIG_FILE has not been set.")
+
+ stdout, err := wsk.RunCommand("property", "unset", "--auth", "--apihost", "--apiversion", "--namespace")
+ assert.Equal(t, nil, err, "The command property unset failed to run.")
+ outputString := string(stdout)
+ assert.Contains(t, outputString, "ok: whisk auth unset",
+ "The output of the command does not contain \"ok: whisk auth unset\".")
+ assert.Contains(t, outputString, "ok: whisk API host unset",
+ "The output of the command does not contain \"ok: whisk API host unset\".")
+ assert.Contains(t, outputString, "ok: whisk API version unset",
+ "The output of the command does not contain \"ok: whisk API version unset\".")
+ assert.Contains(t, outputString, "ok: whisk namespace unset",
+ "The output of the command does not contain \"ok: whisk namespace unset\".")
+
+ stdout, err = wsk.RunCommand("property", "get", "--auth")
+ assert.Equal(t, nil, err, "The command property get --auth failed to run.")
+ assert.Equal(t, "whisk auth", common.RemoveRedundentSpaces(string(stdout)),
+ "The output of the command does not equal to \"whisk auth\".")
+
+ stdout, err = wsk.RunCommand("property", "get", "--apihost")
+ assert.Equal(t, nil, err, "The command property get --apihost failed to run.")
+ assert.Equal(t, "whisk API host", common.RemoveRedundentSpaces(string(stdout)),
+ "The output of the command does not equal to \"whisk API host\".")
+
+ stdout, err = wsk.RunCommand("property", "get", "--namespace")
+ assert.Equal(t, nil, err, "The command property get --namespace failed to run.")
+ assert.Equal(t, "whisk namespace _", common.RemoveRedundentSpaces(string(stdout)),
+ "The output of the command does not equal to \"whisk namespace _\".")
+
+ common.DeleteFile(tmpProp)
}
// Test case to set auth in property file.
func TestSetAuth(t *testing.T) {
- common.CreateFile(tmpProp)
+ common.CreateFile(tmpProp)
- os.Setenv("WSK_CONFIG_FILE", tmpProp)
- assert.Equal(t, os.Getenv("WSK_CONFIG_FILE"), tmpProp, "The environment variable WSK_CONFIG_FILE has not been set.")
+ os.Setenv("WSK_CONFIG_FILE", tmpProp)
+ assert.Equal(t, os.Getenv("WSK_CONFIG_FILE"), tmpProp, "The environment variable WSK_CONFIG_FILE has not been set.")
- _, err := wsk.RunCommand("property", "set", "--auth", "testKey")
- assert.Equal(t, nil, err, "The command property set --auth testKey failed to run.")
- output := common.ReadFile(tmpProp)
- assert.Contains(t, output, "AUTH=testKey",
- "The wsk property file does not contain \"AUTH=testKey\".")
- common.DeleteFile(tmpProp)
+ _, err := wsk.RunCommand("property", "set", "--auth", "testKey")
+ assert.Equal(t, nil, err, "The command property set --auth testKey failed to run.")
+ output := common.ReadFile(tmpProp)
+ assert.Contains(t, output, "AUTH=testKey",
+ "The wsk property file does not contain \"AUTH=testKey\".")
+ common.DeleteFile(tmpProp)
}
// Test case to set multiple property values with single command.
func TestSetMultipleValues(t *testing.T) {
- common.CreateFile(tmpProp)
-
- os.Setenv("WSK_CONFIG_FILE", tmpProp)
- assert.Equal(t, os.Getenv("WSK_CONFIG_FILE"), tmpProp, "The environment variable WSK_CONFIG_FILE has not been set.")
-
- _, err := wsk.RunCommand("property", "set", "--auth", "testKey", "--apihost", "openwhisk.ng.bluemix.net",
- "--apiversion", "v1")
- assert.Equal(t, nil, err, "The command property set --auth --apihost --apiversion failed to run.")
- output := common.ReadFile(tmpProp)
- assert.Contains(t, output, "AUTH=testKey", "The wsk property file does not contain \"AUTH=testKey\".")
- assert.Contains(t, output, "APIHOST=openwhisk.ng.bluemix.net",
- "The wsk property file does not contain \"APIHOST=openwhisk.ng.bluemix.net\".")
- assert.Contains(t, output, "APIVERSION=v1", "The wsk property file does not contain \"APIVERSION=v1\".")
- common.DeleteFile(tmpProp)
+ common.CreateFile(tmpProp)
+
+ os.Setenv("WSK_CONFIG_FILE", tmpProp)
+ assert.Equal(t, os.Getenv("WSK_CONFIG_FILE"), tmpProp, "The environment variable WSK_CONFIG_FILE has not been set.")
+
+ _, err := wsk.RunCommand("property", "set", "--auth", "testKey", "--apihost", "openwhisk.ng.bluemix.net",
+ "--apiversion", "v1")
+ assert.Equal(t, nil, err, "The command property set --auth --apihost --apiversion failed to run.")
+ output := common.ReadFile(tmpProp)
+ assert.Contains(t, output, "AUTH=testKey", "The wsk property file does not contain \"AUTH=testKey\".")
+ assert.Contains(t, output, "APIHOST=openwhisk.ng.bluemix.net",
+ "The wsk property file does not contain \"APIHOST=openwhisk.ng.bluemix.net\".")
+ assert.Contains(t, output, "APIVERSION=v1", "The wsk property file does not contain \"APIVERSION=v1\".")
+ common.DeleteFile(tmpProp)
}
// Test case to reject bad command.
func TestRejectBadComm(t *testing.T) {
- common.CreateFile(tmpProp)
+ common.CreateFile(tmpProp)
- os.Setenv("WSK_CONFIG_FILE", tmpProp)
- assert.Equal(t, os.Getenv("WSK_CONFIG_FILE"), tmpProp, "The environment variable WSK_CONFIG_FILE has not been set.")
+ os.Setenv("WSK_CONFIG_FILE", tmpProp)
+ assert.Equal(t, os.Getenv("WSK_CONFIG_FILE"), tmpProp, "The environment variable WSK_CONFIG_FILE has not been set.")
- stdout, err := wsk.RunCommand("bogus")
- assert.NotEqual(t, nil, err, "The command bogus should fail to run.")
- assert.Contains(t, string(stdout), "Run 'wsk --help' for usage",
- "The output of the command does not contain \"Run 'wsk --help' for usage\".")
- common.DeleteFile(tmpProp)
+ stdout, err := wsk.RunCommand("bogus")
+ assert.NotEqual(t, nil, err, "The command bogus should fail to run.")
+ assert.Contains(t, string(stdout), "Run 'wsk --help' for usage",
+ "The output of the command does not contain \"Run 'wsk --help' for usage\".")
+ common.DeleteFile(tmpProp)
}
// Test case to reject a command when the API host is not set.
func TestRejectCommAPIHostNotSet(t *testing.T) {
- common.CreateFile(tmpProp)
+ common.CreateFile(tmpProp)
- os.Setenv("WSK_CONFIG_FILE", tmpProp)
- assert.Equal(t, os.Getenv("WSK_CONFIG_FILE"), tmpProp, "The environment variable WSK_CONFIG_FILE has not been set.")
+ os.Setenv("WSK_CONFIG_FILE", tmpProp)
+ assert.Equal(t, os.Getenv("WSK_CONFIG_FILE"), tmpProp, "The environment variable WSK_CONFIG_FILE has not been set.")
- stdout, err := wsk.RunCommand("property", "get")
- assert.NotEqual(t, nil, err, "The command property get --apihost --apiversion should fail to run.")
- assert.Contains(t, common.RemoveRedundentSpaces(string(stdout)),
- "The API host is not valid: An API host must be provided",
- "The output of the command does not contain \"The API host is not valid: An API host must be provided\".")
- common.DeleteFile(tmpProp)
+ stdout, err := wsk.RunCommand("property", "get")
+ assert.NotEqual(t, nil, err, "The command property get --apihost --apiversion should fail to run.")
+ assert.Contains(t, common.RemoveRedundentSpaces(string(stdout)),
+ "The API host is not valid: An API host must be provided",
+ "The output of the command does not contain \"The API host is not valid: An API host must be provided\".")
+ common.DeleteFile(tmpProp)
}
func initInvalidArgsNotEnoughParamsArgs() {
- invalidArgs = []common.InvalidArg{
- common.InvalidArg{
- Cmd: []string{"action", "create", "actionName", "-p"},
- Err: invalidParamMsg,
- },
- common.InvalidArg{
- Cmd: []string{"action", "create", "actionName", "-p", "key"},
- Err: invalidParamMsg,
- },
- common.InvalidArg{
- Cmd: []string{"action", "create", "actionName", "-P"},
- Err: invalidParamFileMsg,
- },
- common.InvalidArg{
- Cmd: []string{"action", "update", "actionName", "-p"},
- Err: invalidParamMsg,
- },
- common.InvalidArg{
- Cmd: []string{"action", "update", "actionName", "-p", "key"},
- Err: invalidParamMsg,
- },
- common.InvalidArg{
- Cmd: []string{"action", "update", "actionName", "-P"},
- Err: invalidParamFileMsg,
- },
- common.InvalidArg{
- Cmd: []string{"action", "invoke", "actionName", "-p"},
- Err: invalidParamMsg,
- },
- common.InvalidArg{
- Cmd: []string{"action", "invoke", "actionName", "-p", "key"},
- Err: invalidParamMsg,
- },
- common.InvalidArg{
- Cmd: []string{"action", "invoke", "actionName", "-P"},
- Err: invalidParamFileMsg,
- },
- common.InvalidArg{
- Cmd: []string{"action", "create", "actionName", "-a"},
- Err: invalidAnnotMsg,
- },
- common.InvalidArg{
- Cmd: []string{"action", "create", "actionName", "-a", "key"},
- Err: invalidAnnotMsg,
- },
- common.InvalidArg{
- Cmd: []string{"action", "create", "actionName", "-A"},
- Err: invalidAnnotFileMsg,
- },
- common.InvalidArg{
- Cmd: []string{"action", "update", "actionName", "-a"},
- Err: invalidAnnotMsg,
- },
- common.InvalidArg{
- Cmd: []string{"action", "update", "actionName", "-a", "key"},
- Err: invalidAnnotMsg,
- },
- common.InvalidArg{
- Cmd: []string{"action", "update", "actionName", "-A"},
- Err: invalidAnnotFileMsg,
- },
- common.InvalidArg{
- Cmd: []string{"action", "invoke", "actionName", "-a"},
- Err: invalidAnnotMsg,
- },
- common.InvalidArg{
- Cmd: []string{"action", "invoke", "actionName", "-a", "key"},
- Err: invalidAnnotMsg,
- },
- common.InvalidArg{
- Cmd: []string{"action", "invoke", "actionName", "-A"},
- Err: invalidAnnotFileMsg,
- },
- common.InvalidArg{
- Cmd: []string{"package", "create", "packageName", "-p"},
- Err: invalidParamMsg,
- },
- common.InvalidArg{
- Cmd: []string{"package", "create", "packageName", "-p", "key"},
- Err: invalidParamMsg,
- },
- common.InvalidArg{
- Cmd: []string{"package", "create", "packageName", "-P"},
- Err: invalidParamFileMsg,
- },
- common.InvalidArg{
- Cmd: []string{"package", "update", "packageName", "-p"},
- Err: invalidParamMsg,
- },
- common.InvalidArg{
- Cmd: []string{"package", "update", "packageName", "-p", "key"},
- Err: invalidParamMsg,
- },
- common.InvalidArg{
- Cmd: []string{"package", "update", "packageName", "-P"},
- Err: invalidParamFileMsg,
- },
- common.InvalidArg{
- Cmd: []string{"package", "bind", "packageName", "boundPackageName", "-p"},
- Err: invalidParamMsg,
- },
- common.InvalidArg{
- Cmd: []string{"package", "bind", "packageName", "boundPackageName", "-p", "key"},
- Err: invalidParamMsg,
- },
- common.InvalidArg{
- Cmd: []string{"package", "bind", "packageName", "boundPackageName", "-P"},
- Err: invalidParamFileMsg,
- },
- common.InvalidArg{
- Cmd: []string{"package", "create", "packageName", "-a"},
- Err: invalidAnnotMsg,
- },
- common.InvalidArg{
- Cmd: []string{"package", "create", "packageName", "-a", "key"},
- Err: invalidAnnotMsg,
- },
- common.InvalidArg{
- Cmd: []string{"package", "create", "packageName", "-A"},
- Err: invalidAnnotFileMsg,
- },
- common.InvalidArg{
- Cmd: []string{"package", "update", "packageName", "-a"},
- Err: invalidAnnotMsg,
- },
- common.InvalidArg{
- Cmd: []string{"package", "update", "packageName", "-a", "key"},
- Err: invalidAnnotMsg,
- },
- common.InvalidArg{
- Cmd: []string{"package", "update", "packageName", "-A"},
- Err: invalidAnnotFileMsg,
- },
- common.InvalidArg{
- Cmd: []string{"package", "bind", "packageName", "boundPackageName", "-a"},
- Err: invalidAnnotMsg,
- },
- common.InvalidArg{
- Cmd: []string{"package", "bind", "packageName", "boundPackageName", "-a", "key"},
- Err: invalidAnnotMsg,
- },
- common.InvalidArg{
- Cmd: []string{"package", "bind", "packageName", "boundPackageName", "-A"},
- Err: invalidAnnotFileMsg,
- },
- common.InvalidArg{
- Cmd: []string{"trigger", "create", "triggerName", "-p"},
- Err: invalidParamMsg,
- },
- common.InvalidArg{
- Cmd: []string{"trigger", "create", "triggerName", "-p", "key"},
- Err: invalidParamMsg,
- },
- common.InvalidArg{
- Cmd: []string{"trigger", "create", "triggerName", "-P"},
- Err: invalidParamFileMsg,
- },
- common.InvalidArg{
- Cmd: []string{"trigger", "update", "triggerName", "-p"},
- Err: invalidParamMsg,
- },
- common.InvalidArg{
- Cmd: []string{"trigger", "update", "triggerName", "-p", "key"},
- Err: invalidParamMsg,
- },
- common.InvalidArg{
- Cmd: []string{"trigger", "update", "triggerName", "-P"},
- Err: invalidParamFileMsg,
- },
- common.InvalidArg{
- Cmd: []string{"trigger", "fire", "triggerName", "-p"},
- Err: invalidParamMsg,
- },
- common.InvalidArg{
- Cmd: []string{"trigger", "fire", "triggerName", "-p", "key"},
- Err: invalidParamMsg,
- },
- common.InvalidArg{
- Cmd: []string{"trigger", "fire", "triggerName", "-P"},
- Err: invalidParamFileMsg,
- },
- common.InvalidArg{
- Cmd: []string{"trigger", "create", "triggerName", "-a"},
- Err: invalidAnnotMsg,
- },
- common.InvalidArg{
- Cmd: []string{"trigger", "create", "triggerName", "-a", "key"},
- Err: invalidAnnotMsg,
- },
- common.InvalidArg{
- Cmd: []string{"trigger", "create", "triggerName", "-A"},
- Err: invalidAnnotFileMsg,
- },
- common.InvalidArg{
- Cmd: []string{"trigger", "update", "triggerName", "-a"},
- Err: invalidAnnotMsg,
- },
- common.InvalidArg{
- Cmd: []string{"trigger", "update", "triggerName", "-a", "key"},
- Err: invalidAnnotMsg,
- },
- common.InvalidArg{
- Cmd: []string{"trigger", "update", "triggerName", "-A"},
- Err: invalidAnnotFileMsg,
- },
- common.InvalidArg{
- Cmd: []string{"trigger", "fire", "triggerName", "-a"},
- Err: invalidAnnotMsg,
- },
- common.InvalidArg{
- Cmd: []string{"trigger", "fire", "triggerName", "-a", "key"},
- Err: invalidAnnotMsg,
- },
- common.InvalidArg{
- Cmd: []string{"trigger", "fire", "triggerName", "-A"},
- Err: invalidAnnotFileMsg,
- },
- }
+ invalidArgs = []common.InvalidArg{
+ {
+ Cmd: []string{"action", "create", "actionName", "-p"},
+ Err: invalidParamMsg,
+ },
+ {
+ Cmd: []string{"action", "create", "actionName", "-p", "key"},
+ Err: invalidParamMsg,
+ },
+ {
+ Cmd: []string{"action", "create", "actionName", "-P"},
+ Err: invalidParamFileMsg,
+ },
+ {
+ Cmd: []string{"action", "update", "actionName", "-p"},
+ Err: invalidParamMsg,
+ },
+ {
+ Cmd: []string{"action", "update", "actionName", "-p", "key"},
+ Err: invalidParamMsg,
+ },
+ {
+ Cmd: []string{"action", "update", "actionName", "-P"},
+ Err: invalidParamFileMsg,
+ },
+ {
+ Cmd: []string{"action", "invoke", "actionName", "-p"},
+ Err: invalidParamMsg,
+ },
+ {
+ Cmd: []string{"action", "invoke", "actionName", "-p", "key"},
+ Err: invalidParamMsg,
+ },
+ {
+ Cmd: []string{"action", "invoke", "actionName", "-P"},
+ Err: invalidParamFileMsg,
+ },
+ {
+ Cmd: []string{"action", "create", "actionName", "-a"},
+ Err: invalidAnnotMsg,
+ },
+ {
+ Cmd: []string{"action", "create", "actionName", "-a", "key"},
+ Err: invalidAnnotMsg,
+ },
+ {
+ Cmd: []string{"action", "create", "actionName", "-A"},
+ Err: invalidAnnotFileMsg,
+ },
+ {
+ Cmd: []string{"action", "update", "actionName", "-a"},
+ Err: invalidAnnotMsg,
+ },
+ {
+ Cmd: []string{"action", "update", "actionName", "-a", "key"},
+ Err: invalidAnnotMsg,
+ },
+ {
+ Cmd: []string{"action", "update", "actionName", "-A"},
+ Err: invalidAnnotFileMsg,
+ },
+ {
+ Cmd: []string{"action", "invoke", "actionName", "-a"},
+ Err: invalidAnnotMsg,
+ },
+ {
+ Cmd: []string{"action", "invoke", "actionName", "-a", "key"},
+ Err: invalidAnnotMsg,
+ },
+ {
+ Cmd: []string{"action", "invoke", "actionName", "-A"},
+ Err: invalidAnnotFileMsg,
+ },
+ {
+ Cmd: []string{"package", "create", "packageName", "-p"},
+ Err: invalidParamMsg,
+ },
+ {
+ Cmd: []string{"package", "create", "packageName", "-p", "key"},
+ Err: invalidParamMsg,
+ },
+ {
+ Cmd: []string{"package", "create", "packageName", "-P"},
+ Err: invalidParamFileMsg,
+ },
+ {
+ Cmd: []string{"package", "update", "packageName", "-p"},
+ Err: invalidParamMsg,
+ },
+ {
+ Cmd: []string{"package", "update", "packageName", "-p", "key"},
+ Err: invalidParamMsg,
+ },
+ {
+ Cmd: []string{"package", "update", "packageName", "-P"},
+ Err: invalidParamFileMsg,
+ },
+ {
+ Cmd: []string{"package", "bind", "packageName", "boundPackageName", "-p"},
+ Err: invalidParamMsg,
+ },
+ {
+ Cmd: []string{"package", "bind", "packageName", "boundPackageName", "-p", "key"},
+ Err: invalidParamMsg,
+ },
+ {
+ Cmd: []string{"package", "bind", "packageName", "boundPackageName", "-P"},
+ Err: invalidParamFileMsg,
+ },
+ {
+ Cmd: []string{"package", "create", "packageName", "-a"},
+ Err: invalidAnnotMsg,
+ },
+ {
+ Cmd: []string{"package", "create", "packageName", "-a", "key"},
+ Err: invalidAnnotMsg,
+ },
+ {
+ Cmd: []string{"package", "create", "packageName", "-A"},
+ Err: invalidAnnotFileMsg,
+ },
+ {
+ Cmd: []string{"package", "update", "packageName", "-a"},
+ Err: invalidAnnotMsg,
+ },
+ {
+ Cmd: []string{"package", "update", "packageName", "-a", "key"},
+ Err: invalidAnnotMsg,
+ },
+ {
+ Cmd: []string{"package", "update", "packageName", "-A"},
+ Err: invalidAnnotFileMsg,
+ },
+ {
+ Cmd: []string{"package", "bind", "packageName", "boundPackageName", "-a"},
+ Err: invalidAnnotMsg,
+ },
+ {
+ Cmd: []string{"package", "bind", "packageName", "boundPackageName", "-a", "key"},
+ Err: invalidAnnotMsg,
+ },
+ {
+ Cmd: []string{"package", "bind", "packageName", "boundPackageName", "-A"},
+ Err: invalidAnnotFileMsg,
+ },
+ {
+ Cmd: []string{"trigger", "create", "triggerName", "-p"},
+ Err: invalidParamMsg,
+ },
+ {
+ Cmd: []string{"trigger", "create", "triggerName", "-p", "key"},
+ Err: invalidParamMsg,
+ },
+ {
+ Cmd: []string{"trigger", "create", "triggerName", "-P"},
+ Err: invalidParamFileMsg,
+ },
+ {
+ Cmd: []string{"trigger", "update", "triggerName", "-p"},
+ Err: invalidParamMsg,
+ },
+ {
+ Cmd: []string{"trigger", "update", "triggerName", "-p", "key"},
+ Err: invalidParamMsg,
+ },
+ {
+ Cmd: []string{"trigger", "update", "triggerName", "-P"},
+ Err: invalidParamFileMsg,
+ },
+ {
+ Cmd: []string{"trigger", "fire", "triggerName", "-p"},
+ Err: invalidParamMsg,
+ },
+ {
+ Cmd: []string{"trigger", "fire", "triggerName", "-p", "key"},
+ Err: invalidParamMsg,
+ },
+ {
+ Cmd: []string{"trigger", "fire", "triggerName", "-P"},
+ Err: invalidParamFileMsg,
+ },
+ {
+ Cmd: []string{"trigger", "create", "triggerName", "-a"},
+ Err: invalidAnnotMsg,
+ },
+ {
+ Cmd: []string{"trigger", "create", "triggerName", "-a", "key"},
+ Err: invalidAnnotMsg,
+ },
+ {
+ Cmd: []string{"trigger", "create", "triggerName", "-A"},
+ Err: invalidAnnotFileMsg,
+ },
+ {
+ Cmd: []string{"trigger", "update", "triggerName", "-a"},
+ Err: invalidAnnotMsg,
+ },
+ {
+ Cmd: []string{"trigger", "update", "triggerName", "-a", "key"},
+ Err: invalidAnnotMsg,
+ },
+ {
+ Cmd: []string{"trigger", "update", "triggerName", "-A"},
+ Err: invalidAnnotFileMsg,
+ },
+ {
+ Cmd: []string{"trigger", "fire", "triggerName", "-a"},
+ Err: invalidAnnotMsg,
+ },
+ {
+ Cmd: []string{"trigger", "fire", "triggerName", "-a", "key"},
+ Err: invalidAnnotMsg,
+ },
+ {
+ Cmd: []string{"trigger", "fire", "triggerName", "-A"},
+ Err: invalidAnnotFileMsg,
+ },
+ }
}
-func initInvalidArgsMissingInvalidParamsAnno(){
- invalidArgs = []common.InvalidArg{
- common.InvalidArg{
- Cmd: []string{"action", "create", "actionName", helloFile, "-P", emptyFile},
- Err: emptyFileMsg,
- },
- common.InvalidArg{
- Cmd: []string{"action", "update", "actionName", helloFile, "-P", emptyFile},
- Err: emptyFileMsg,
- },
- common.InvalidArg{
- Cmd: []string{"action", "invoke", "actionName", "-P", emptyFile},
- Err: emptyFileMsg,
- },
- common.InvalidArg{
- Cmd: []string{"action", "create", "actionName", "-P", emptyFile},
- Err: emptyFileMsg,
- },
- common.InvalidArg{
- Cmd: []string{"action", "update", "actionName", "-P", emptyFile},
- Err: emptyFileMsg,
- },
- common.InvalidArg{
- Cmd: []string{"action", "invoke", "actionName", "-P", emptyFile},
- Err: emptyFileMsg,
- },
- common.InvalidArg{
- Cmd: []string{"package", "create", "packageName", "-P", emptyFile},
- Err: emptyFileMsg,
- },
- common.InvalidArg{
- Cmd: []string{"package", "update", "packageName", "-P", emptyFile},
- Err: emptyFileMsg,
- },
- common.InvalidArg{
- Cmd: []string{"package", "bind", "packageName", "boundPackageName", "-P", emptyFile},
- Err: emptyFileMsg,
- },
- common.InvalidArg{
- Cmd: []string{"package", "create", "packageName", "-P", emptyFile},
- Err: emptyFileMsg,
- },
- common.InvalidArg{
- Cmd: []string{"package", "update", "packageName", "-P", emptyFile},
- Err: emptyFileMsg,
- },
- common.InvalidArg{
- Cmd: []string{"package", "bind", "packageName", "boundPackageName", "-P", emptyFile},
- Err: emptyFileMsg,
- },
- common.InvalidArg{
- Cmd: []string{"trigger", "create", "triggerName", "-P", emptyFile},
- Err: emptyFileMsg,
- },
- common.InvalidArg{
- Cmd: []string{"trigger", "update", "triggerName", "-P", emptyFile},
- Err: emptyFileMsg,
- },
- common.InvalidArg{
- Cmd: []string{"trigger", "fire", "triggerName", "-P", emptyFile},
- Err: emptyFileMsg,
- },
- common.InvalidArg{
- Cmd: []string{"trigger", "create", "triggerName", "-P", emptyFile},
- Err: emptyFileMsg,
- },
- common.InvalidArg{
- Cmd: []string{"trigger", "update", "triggerName", "-P", emptyFile},
- Err: emptyFileMsg,
- },
- common.InvalidArg{
- Cmd: []string{"trigger", "fire", "triggerName", "-P", emptyFile},
- Err: emptyFileMsg,
- },
- common.InvalidArg{
- Cmd: []string{"action", "create", "actionName", helloFile, "-A", missingFile},
- Err: missingFileMsg,
- },
- common.InvalidArg{
- Cmd: []string{"action", "update", "actionName", helloFile, "-A", missingFile},
- Err: missingFileMsg,
- },
- common.InvalidArg{
- Cmd: []string{"action", "invoke", "actionName", "-A", missingFile},
- Err: missingFileMsg,
- },
- common.InvalidArg{
- Cmd: []string{"action", "create", "actionName", "-A", missingFile},
- Err: missingFileMsg,
- },
- common.InvalidArg{
- Cmd: []string{"action", "update", "actionName", "-A", missingFile},
- Err: missingFileMsg,
- },
- common.InvalidArg{
- Cmd: []string{"action", "invoke", "actionName", "-A", missingFile},
- Err: missingFileMsg,
- },
- common.InvalidArg{
- Cmd: []string{"package", "create", "packageName", "-A", missingFile},
- Err: missingFileMsg,
- },
- common.InvalidArg{
- Cmd: []string{"package", "update", "packageName", "-A", missingFile},
- Err: missingFileMsg,
- },
- common.InvalidArg{
- Cmd: []string{"package", "bind", "packageName", "boundPackageName", "-A", missingFile},
- Err: missingFileMsg,
- },
- common.InvalidArg{
- Cmd: []string{"trigger", "create", "triggerName", "-A", missingFile},
- Err: missingFileMsg,
- },
- common.InvalidArg{
- Cmd: []string{"trigger", "update", "triggerName", "-A", missingFile},
- Err: missingFileMsg,
- },
- common.InvalidArg{
- Cmd: []string{"trigger", "fire", "triggerName", "-A", missingFile},
- Err: missingFileMsg,
- },
- }
+func initInvalidArgsMissingInvalidParamsAnno() {
+ invalidArgs = []common.InvalidArg{
+ {
+ Cmd: []string{"action", "create", "actionName", helloFile, "-P", emptyFile},
+ Err: emptyFileMsg,
+ },
+ {
+ Cmd: []string{"action", "update", "actionName", helloFile, "-P", emptyFile},
+ Err: emptyFileMsg,
+ },
+ {
+ Cmd: []string{"action", "invoke", "actionName", "-P", emptyFile},
+ Err: emptyFileMsg,
+ },
+ {
+ Cmd: []string{"action", "create", "actionName", "-P", emptyFile},
+ Err: emptyFileMsg,
+ },
+ {
+ Cmd: []string{"action", "update", "actionName", "-P", emptyFile},
+ Err: emptyFileMsg,
+ },
+ {
+ Cmd: []string{"action", "invoke", "actionName", "-P", emptyFile},
+ Err: emptyFileMsg,
+ },
+ {
+ Cmd: []string{"package", "create", "packageName", "-P", emptyFile},
+ Err: emptyFileMsg,
+ },
+ {
+ Cmd: []string{"package", "update", "packageName", "-P", emptyFile},
+ Err: emptyFileMsg,
+ },
+ {
+ Cmd: []string{"package", "bind", "packageName", "boundPackageName", "-P", emptyFile},
+ Err: emptyFileMsg,
+ },
+ {
+ Cmd: []string{"package", "create", "packageName", "-P", emptyFile},
+ Err: emptyFileMsg,
+ },
+ {
+ Cmd: []string{"package", "update", "packageName", "-P", emptyFile},
+ Err: emptyFileMsg,
+ },
+ {
+ Cmd: []string{"package", "bind", "packageName", "boundPackageName", "-P", emptyFile},
+ Err: emptyFileMsg,
+ },
+ {
+ Cmd: []string{"trigger", "create", "triggerName", "-P", emptyFile},
+ Err: emptyFileMsg,
+ },
+ {
+ Cmd: []string{"trigger", "update", "triggerName", "-P", emptyFile},
+ Err: emptyFileMsg,
+ },
+ {
+ Cmd: []string{"trigger", "fire", "triggerName", "-P", emptyFile},
+ Err: emptyFileMsg,
+ },
+ {
+ Cmd: []string{"trigger", "create", "triggerName", "-P", emptyFile},
+ Err: emptyFileMsg,
+ },
+ {
+ Cmd: []string{"trigger", "update", "triggerName", "-P", emptyFile},
+ Err: emptyFileMsg,
+ },
+ {
+ Cmd: []string{"trigger", "fire", "triggerName", "-P", emptyFile},
+ Err: emptyFileMsg,
+ },
+ {
+ Cmd: []string{"action", "create", "actionName", helloFile, "-A", missingFile},
+ Err: missingFileMsg,
+ },
+ {
+ Cmd: []string{"action", "update", "actionName", helloFile, "-A", missingFile},
+ Err: missingFileMsg,
+ },
+ {
+ Cmd: []string{"action", "invoke", "actionName", "-A", missingFile},
+ Err: missingFileMsg,
+ },
+ {
+ Cmd: []string{"action", "create", "actionName", "-A", missingFile},
+ Err: missingFileMsg,
+ },
+ {
+ Cmd: []string{"action", "update", "actionName", "-A", missingFile},
+ Err: missingFileMsg,
+ },
+ {
+ Cmd: []string{"action", "invoke", "actionName", "-A", missingFile},
+ Err: missingFileMsg,
+ },
+ {
+ Cmd: []string{"package", "create", "packageName", "-A", missingFile},
+ Err: missingFileMsg,
+ },
+ {
+ Cmd: []string{"package", "update", "packageName", "-A", missingFile},
+ Err: missingFileMsg,
+ },
+ {
+ Cmd: []string{"package", "bind", "packageName", "boundPackageName", "-A", missingFile},
+ Err: missingFileMsg,
+ },
+ {
+ Cmd: []string{"trigger", "create", "triggerName", "-A", missingFile},
+ Err: missingFileMsg,
+ },
+ {
+ Cmd: []string{"trigger", "update", "triggerName", "-A", missingFile},
+ Err: missingFileMsg,
+ },
+ {
+ Cmd: []string{"trigger", "fire", "triggerName", "-A", missingFile},
+ Err: missingFileMsg,
+ },
+ }
}
// Test case to reject commands that are executed with not enough param or annotation arguments.
func TestRejectCommandsNotEnoughParamsArgs(t *testing.T) {
- initInvalidArgsNotEnoughParamsArgs()
- for _, invalidArg := range invalidArgs {
- stdout, err := wsk.RunCommand(invalidArg.Cmd...)
- outputString := string(stdout)
- assert.NotEqual(t, nil, err, "The command should fail to run.")
- assert.Equal(t, "exit status 1", err.Error(), "The error should be exit status 1.")
- assert.Contains(t, outputString, invalidArg.Err,
- "The output of the command does not contain " + invalidArg.Err)
- assert.Contains(t, outputString, "Run 'wsk --help' for usage",
- "The output of the command does not contain \"Run 'wsk --help' for usage\".")
- }
+ initInvalidArgsNotEnoughParamsArgs()
+ for _, invalidArg := range invalidArgs {
+ stdout, err := wsk.RunCommand(invalidArg.Cmd...)
+ outputString := string(stdout)
+ assert.NotEqual(t, nil, err, "The command should fail to run.")
+ assert.Equal(t, "exit status 1", err.Error(), "The error should be exit status 1.")
+ assert.Contains(t, outputString, invalidArg.Err,
+ "The output of the command does not contain "+invalidArg.Err)
+ assert.Contains(t, outputString, "Run 'wsk --help' for usage",
+ "The output of the command does not contain \"Run 'wsk --help' for usage\".")
+ }
}
// Test case to reject commands that are executed with a missing or invalid parameter or annotation file.
func TestRejectCommandsMissingIvalidParamsAnno(t *testing.T) {
- initInvalidArgsMissingInvalidParamsAnno()
- for _, invalidArg := range invalidArgs {
- stdout, err := wsk.RunCommand(invalidArg.Cmd...)
- outputString := string(stdout)
- assert.NotEqual(t, nil, err, "The command should fail to run.")
- assert.Equal(t, "exit status 2", err.Error(), "The error should be exit status 1.")
- assert.Contains(t, outputString, invalidArg.Err,
- "The output of the command does not contain " + invalidArg.Err)
- assert.Contains(t, outputString, "Run 'wsk --help' for usage",
- "The output of the command does not contain \"Run 'wsk --help' for usage\".")
- }
+ initInvalidArgsMissingInvalidParamsAnno()
+ for _, invalidArg := range invalidArgs {
+ stdout, err := wsk.RunCommand(invalidArg.Cmd...)
+ outputString := string(stdout)
+ assert.NotEqual(t, nil, err, "The command should fail to run.")
+ assert.Equal(t, "exit status 2", err.Error(), "The error should be exit status 1.")
+ assert.Contains(t, outputString, invalidArg.Err,
+ "The output of the command does not contain "+invalidArg.Err)
+ assert.Contains(t, outputString, "Run 'wsk --help' for usage",
+ "The output of the command does not contain \"Run 'wsk --help' for usage\".")
+ }
}
diff --git a/tests/src/integration/common/utils.go b/tests/src/integration/common/utils.go
index c24b23e..0d98af4 100644
--- a/tests/src/integration/common/utils.go
+++ b/tests/src/integration/common/utils.go
@@ -17,104 +17,104 @@
package common
import (
- "fmt"
- "os"
- "unicode"
- "io"
- "path"
- "runtime"
- "strings"
+ "fmt"
+ "io"
+ "os"
+ "path"
+ "runtime"
+ "strings"
+ "unicode"
)
func checkError(err error) {
- if err != nil {
- fmt.Println(err.Error())
- os.Exit(0)
- }
+ if err != nil {
+ fmt.Println(err.Error())
+ os.Exit(0)
+ }
}
func CreateFile(filePath string) {
- var _, err = os.Stat(filePath)
+ var _, err = os.Stat(filePath)
- if os.IsNotExist(err) {
- var file, err = os.Create(filePath)
- checkError(err)
- defer file.Close()
- }
- return
+ if os.IsNotExist(err) {
+ var file, err = os.Create(filePath)
+ checkError(err)
+ defer file.Close()
+ }
+ return
}
func ReadFile(filePath string) string {
- var file, err = os.OpenFile(filePath, os.O_RDWR, 0644)
- checkError(err)
- defer file.Close()
+ var file, err = os.OpenFile(filePath, os.O_RDWR, 0644)
+ checkError(err)
+ defer file.Close()
- var text = make([]byte, 1024)
- for {
- n, err := file.Read(text)
- if err != io.EOF {
- checkError(err)
- }
- if n == 0 {
- break
- }
- }
- return string(text)
+ var text = make([]byte, 1024)
+ for {
+ n, err := file.Read(text)
+ if err != io.EOF {
+ checkError(err)
+ }
+ if n == 0 {
+ break
+ }
+ }
+ return string(text)
}
func WriteFile(filePath string, lines []string) {
- var file, err = os.OpenFile(filePath, os.O_RDWR, 0644)
- checkError(err)
- defer file.Close()
+ var file, err = os.OpenFile(filePath, os.O_RDWR, 0644)
+ checkError(err)
+ defer file.Close()
- for _, each := range lines {
- _, err = file.WriteString(each + "\n")
- checkError(err)
- }
+ for _, each := range lines {
+ _, err = file.WriteString(each + "\n")
+ checkError(err)
+ }
- err = file.Sync()
- checkError(err)
+ err = file.Sync()
+ checkError(err)
}
func DeleteFile(filePath string) {
- var err = os.Remove(filePath)
- checkError(err)
+ var err = os.Remove(filePath)
+ checkError(err)
}
func RemoveRedundentSpaces(in string) (out string) {
- white := false
- for _, c := range in {
- if unicode.IsSpace(c) {
- if !white {
- out = out + " "
- }
- white = true
- } else {
- out = out + string(c)
- white = false
- }
- }
- out = strings.TrimSpace(out)
- return
+ white := false
+ for _, c := range in {
+ if unicode.IsSpace(c) {
+ if !white {
+ out = out + " "
+ }
+ white = true
+ } else {
+ out = out + string(c)
+ white = false
+ }
+ }
+ out = strings.TrimSpace(out)
+ return
}
func GetTestActionFilename(fileName string) string {
- return GetRepoPath() + "/tests/src/dat/" + fileName
+ return GetRepoPath() + "/tests/src/dat/" + fileName
}
func GetRepoPath() string {
- return os.Getenv("GOPATH") + "/src/github.com/apache/incubator-openwhisk-cli"
+ return os.Getenv("GOPATH") + "/src/github.com/apache/incubator-openwhisk-cli"
}
func GetBinPath() string {
- _, goFileName, _, _ := runtime.Caller(1)
- // Yes, this assumes we're using the official build script. I haven't
- // figured out a better approach yet given the panoply of options.
- // Maybe some sort of Go search path?
- return path.Join(path.Dir(goFileName), "../../../../build")
+ _, goFileName, _, _ := runtime.Caller(1)
+ // Yes, this assumes we're using the official build script. I haven't
+ // figured out a better approach yet given the panoply of options.
+ // Maybe some sort of Go search path?
+ return path.Join(path.Dir(goFileName), "../../../../build")
}
type InvalidArg struct {
- Cmd []string
- Err string
+ Cmd []string
+ Err string
}
diff --git a/tests/src/integration/common/wsk.go b/tests/src/integration/common/wsk.go
index 4af89e1..d6481dc 100644
--- a/tests/src/integration/common/wsk.go
+++ b/tests/src/integration/common/wsk.go
@@ -17,55 +17,55 @@
package common
import (
- "os"
- "os/exec"
- "github.com/apache/incubator-openwhisk-client-go/whisk"
+ "github.com/apache/incubator-openwhisk-client-go/whisk"
+ "os"
+ "os/exec"
)
const cmd = "wsk"
const arg = "-i"
type Wsk struct {
- Path string
- Arg []string
- Dir string
- Wskprops *whisk.Wskprops
+ Path string
+ Arg []string
+ Dir string
+ Wskprops *whisk.Wskprops
}
func NewWsk() *Wsk {
- return NewWskWithPath(GetBinPath())
+ return NewWskWithPath(GetBinPath())
}
func NewWskWithPath(path string) *Wsk {
- var dep Wsk
- dep.Path = cmd
- dep.Arg = []string{arg}
- dep.Dir = path
- pi := whisk.PropertiesImp{
- OsPackage: whisk.OSPackageImp{},
- }
- dep.Wskprops, _ = whisk.GetDefaultWskProp(pi)
- return &dep
+ var dep Wsk
+ dep.Path = cmd
+ dep.Arg = []string{arg}
+ dep.Dir = path
+ pi := whisk.PropertiesImp{
+ OsPackage: whisk.OSPackageImp{},
+ }
+ dep.Wskprops, _ = whisk.GetDefaultWskProp(pi)
+ return &dep
}
-func (wsk *Wsk)Exists() bool {
- _, err := os.Stat(wsk.Dir + "/" + wsk.Path);
- if err == nil {
- return true
- } else {
- return false
- }
+func (wsk *Wsk) Exists() bool {
+ _, err := os.Stat(wsk.Dir + "/" + wsk.Path)
+ if err == nil {
+ return true
+ } else {
+ return false
+ }
}
-func (wsk *Wsk)RunCommand(s ...string) ([]byte, error) {
- cs := wsk.Arg
- cs = append(cs, s...)
- command := exec.Command(wsk.Dir + "/" + wsk.Path, cs...)
- command.Dir = wsk.Dir
- return command.CombinedOutput()
+func (wsk *Wsk) RunCommand(s ...string) ([]byte, error) {
+ cs := wsk.Arg
+ cs = append(cs, s...)
+ command := exec.Command(wsk.Dir+"/"+wsk.Path, cs...)
+ command.Dir = wsk.Dir
+ return command.CombinedOutput()
}
-func (wsk *Wsk)ListNamespaces() ([]byte, error) {
- return wsk.RunCommand("namespace", "list", "--apihost", wsk.Wskprops.APIHost,
- "--auth", wsk.Wskprops.AuthKey)
+func (wsk *Wsk) ListNamespaces() ([]byte, error) {
+ return wsk.RunCommand("namespace", "list", "--apihost", wsk.Wskprops.APIHost,
+ "--auth", wsk.Wskprops.AuthKey)
}
diff --git a/tests/src/integration/integration_test.go b/tests/src/integration/integration_test.go
index ab368a2..f6245c9 100644
--- a/tests/src/integration/integration_test.go
+++ b/tests/src/integration/integration_test.go
@@ -20,12 +20,12 @@
package tests
import (
- "testing"
- "github.com/stretchr/testify/assert"
- "github.com/apache/incubator-openwhisk-cli/tests/src/integration/common"
- "os"
- "strings"
- "fmt"
+ "fmt"
+ "github.com/apache/incubator-openwhisk-cli/tests/src/integration/common"
+ "github.com/stretchr/testify/assert"
+ "os"
+ "strings"
+ "testing"
)
var invalidArgs []common.InvalidArg
@@ -52,280 +52,280 @@ var apiListReqMsg = "Optional parameters are: API base path (or API name), API r
var invalidShared = "Cannot use value '" + invalidArg + "' for shared"
func initInvalidArgs() {
- invalidArgs = []common.InvalidArg{
- common.InvalidArg {
- Cmd: []string{"action", "create"},
- Err: tooFewArgsMsg + " " + actionNameActionReqMsg,
- },
- common.InvalidArg {
- Cmd: []string{"action", "create", "someAction"},
- Err: tooFewArgsMsg + " " + actionNameActionReqMsg,
- },
- common.InvalidArg {
- Cmd: []string{"action", "create", "actionName", "artifactName", invalidArg},
- Err: tooManyArgsMsg + invalidArg + ".",
- },
- common.InvalidArg {
- Cmd: []string{"action", "update"},
- Err: tooFewArgsMsg + " " + actionNameReqMsg + " " + actionOptMsg,
- },
- common.InvalidArg {
- Cmd: []string{"action", "update", "actionName", "artifactName", invalidArg},
- Err: tooManyArgsMsg + invalidArg + ". " + actionNameReqMsg + " " + actionOptMsg,
- },
- common.InvalidArg {
- Cmd: []string{"action", "delete"},
- Err: tooFewArgsMsg + " " + actionNameReqMsg,
- },
- common.InvalidArg {
- Cmd: []string{"action", "delete", "actionName", invalidArg},
- Err: tooManyArgsMsg + invalidArg + ".",
- },
- common.InvalidArg {
- Cmd: []string{"action", "get"},
- Err: tooFewArgsMsg + " " + actionNameReqMsg,
- },
- common.InvalidArg {
- Cmd: []string{"action", "get", "actionName", "namespace", invalidArg},
- Err: tooManyArgsMsg + invalidArg + ".",
- },
- common.InvalidArg {
- Cmd: []string{"action", "list", "namespace", invalidArg},
- Err: tooManyArgsMsg + invalidArg + ". " + optNamespaceMsg,
- },
- common.InvalidArg {
- Cmd: []string{"action", "invoke"},
- Err: tooFewArgsMsg + " " + actionNameReqMsg,
- },
- common.InvalidArg {
- Cmd: []string{"action", "invoke", "actionName", invalidArg},
- Err: tooManyArgsMsg + invalidArg + ".",
- },
- common.InvalidArg {
- Cmd: []string{"activation", "list", "namespace", invalidArg},
- Err: tooManyArgsMsg + invalidArg + ". " + optNamespaceMsg,
- },
- common.InvalidArg {
- Cmd: []string{"activation", "get"},
- Err: tooFewArgsMsg + " " + activationIdReq,
- },
- common.InvalidArg {
- Cmd: []string{"activation", "get", "activationID", "namespace", invalidArg},
- Err: tooManyArgsMsg + invalidArg + ".",
- },
- common.InvalidArg {
- Cmd: []string{"activation", "logs"},
- Err: tooFewArgsMsg + " " + activationIdReq,
- },
- common.InvalidArg {
- Cmd: []string{"activation", "logs", "activationID", invalidArg},
- Err: tooManyArgsMsg + invalidArg + ".",
- },
+ invalidArgs = []common.InvalidArg{
+ {
+ Cmd: []string{"action", "create"},
+ Err: tooFewArgsMsg + " " + actionNameActionReqMsg,
+ },
+ {
+ Cmd: []string{"action", "create", "someAction"},
+ Err: tooFewArgsMsg + " " + actionNameActionReqMsg,
+ },
+ {
+ Cmd: []string{"action", "create", "actionName", "artifactName", invalidArg},
+ Err: tooManyArgsMsg + invalidArg + ".",
+ },
+ {
+ Cmd: []string{"action", "update"},
+ Err: tooFewArgsMsg + " " + actionNameReqMsg + " " + actionOptMsg,
+ },
+ {
+ Cmd: []string{"action", "update", "actionName", "artifactName", invalidArg},
+ Err: tooManyArgsMsg + invalidArg + ". " + actionNameReqMsg + " " + actionOptMsg,
+ },
+ {
+ Cmd: []string{"action", "delete"},
+ Err: tooFewArgsMsg + " " + actionNameReqMsg,
+ },
+ {
+ Cmd: []string{"action", "delete", "actionName", invalidArg},
+ Err: tooManyArgsMsg + invalidArg + ".",
+ },
+ {
+ Cmd: []string{"action", "get"},
+ Err: tooFewArgsMsg + " " + actionNameReqMsg,
+ },
+ {
+ Cmd: []string{"action", "get", "actionName", "namespace", invalidArg},
+ Err: tooManyArgsMsg + invalidArg + ".",
+ },
+ {
+ Cmd: []string{"action", "list", "namespace", invalidArg},
+ Err: tooManyArgsMsg + invalidArg + ". " + optNamespaceMsg,
+ },
+ {
+ Cmd: []string{"action", "invoke"},
+ Err: tooFewArgsMsg + " " + actionNameReqMsg,
+ },
+ {
+ Cmd: []string{"action", "invoke", "actionName", invalidArg},
+ Err: tooManyArgsMsg + invalidArg + ".",
+ },
+ {
+ Cmd: []string{"activation", "list", "namespace", invalidArg},
+ Err: tooManyArgsMsg + invalidArg + ". " + optNamespaceMsg,
+ },
+ {
+ Cmd: []string{"activation", "get"},
+ Err: tooFewArgsMsg + " " + activationIdReq,
+ },
+ {
+ Cmd: []string{"activation", "get", "activationID", "namespace", invalidArg},
+ Err: tooManyArgsMsg + invalidArg + ".",
+ },
+ {
+ Cmd: []string{"activation", "logs"},
+ Err: tooFewArgsMsg + " " + activationIdReq,
+ },
+ {
+ Cmd: []string{"activation", "logs", "activationID", invalidArg},
+ Err: tooManyArgsMsg + invalidArg + ".",
+ },
- common.InvalidArg {
- Cmd: []string{"activation", "result"},
- Err: tooFewArgsMsg + " " + activationIdReq,
- },
- common.InvalidArg {
- Cmd: []string{"activation", "result", "activationID", invalidArg},
- Err: tooManyArgsMsg + invalidArg + ".",
- },
- common.InvalidArg {
- Cmd: []string{"activation", "poll", "activationID", invalidArg},
- Err: tooManyArgsMsg + invalidArg + ". " + optNamespaceMsg,
- },
- common.InvalidArg {
- Cmd: []string{"namespace", "list", invalidArg},
- Err: tooManyArgsMsg + invalidArg + ". " + noArgsReqMsg,
- },
- common.InvalidArg {
- Cmd: []string{"namespace", "get", invalidArg},
- Err: tooManyArgsMsg + invalidArg + ". " + noArgsReqMsg,
- },
- common.InvalidArg {
- Cmd: []string{"package", "create"},
- Err: tooFewArgsMsg + " " + packageNameReqMsg,
- },
- common.InvalidArg {
- Cmd: []string{"package", "create", "packageName", invalidArg},
- Err: tooManyArgsMsg + invalidArg + ".",
- },
- common.InvalidArg {
- Cmd: []string{"package", "create", "packageName", "--shared", invalidArg},
- Err: invalidShared,
- },
- common.InvalidArg {
- Cmd: []string{"package", "update"},
- Err: tooFewArgsMsg + " " + packageNameReqMsg,
- },
- common.InvalidArg {
- Cmd: []string{"package", "update", "packageName", invalidArg},
- Err: tooManyArgsMsg + invalidArg + ".",
- },
- common.InvalidArg {
- Cmd: []string{"package", "update", "packageName", "--shared", invalidArg},
- Err: invalidShared,
- },
- common.InvalidArg {
- Cmd: []string{"package", "get"},
- Err: tooFewArgsMsg + " " +packageNameReqMsg,
- },
- common.InvalidArg {
- Cmd: []string{"package", "get", "packageName", "namespace", invalidArg},
- Err: tooManyArgsMsg + invalidArg + ".",
- },
- common.InvalidArg {
- Cmd: []string{"package", "bind"},
- Err: tooFewArgsMsg + " " + packageNameBindingReqMsg,
- },
- common.InvalidArg {
- Cmd: []string{"package", "bind", "packageName"},
- Err: tooFewArgsMsg + " " +packageNameBindingReqMsg,
- },
- common.InvalidArg {
- Cmd: []string{"package", "bind", "packageName", "bindingName", invalidArg},
- Err: tooManyArgsMsg + invalidArg + ".",
- },
- common.InvalidArg {
- Cmd: []string{"package", "list", "namespace", invalidArg},
- Err: tooManyArgsMsg + invalidArg + ". " + optNamespaceMsg,
- },
- common.InvalidArg {
- Cmd: []string{"package", "delete"},
- Err: tooFewArgsMsg + " " + packageNameReqMsg,
- },
- common.InvalidArg {
- Cmd: []string{"package", "delete", "namespace", invalidArg},
- Err: tooManyArgsMsg + invalidArg + ".",
- },
- common.InvalidArg {
- Cmd: []string{"package", "refresh", "namespace", invalidArg},
- Err: tooManyArgsMsg + invalidArg + ". " + optNamespaceMsg,
- },
- common.InvalidArg {
- Cmd: []string{"rule", "enable"},
- Err: tooFewArgsMsg + " " + ruleNameReqMsg,
- },
- common.InvalidArg {
- Cmd: []string{"rule", "enable", "ruleName", invalidArg},
- Err: tooManyArgsMsg + invalidArg + ".",
- },
- common.InvalidArg {
- Cmd: []string{"rule", "disable"},
- Err: tooFewArgsMsg + " " + ruleNameReqMsg,
- },
- common.InvalidArg {
- Cmd: []string{"rule", "disable", "ruleName", invalidArg},
- Err: tooManyArgsMsg + invalidArg + ".",
- },
- common.InvalidArg {
- Cmd: []string{"rule", "status"},
- Err: tooFewArgsMsg + " " + ruleNameReqMsg,
- },
- common.InvalidArg {
- Cmd: []string{"rule", "status", "ruleName", invalidArg},
- Err: tooManyArgsMsg + invalidArg + ".",
- },
- common.InvalidArg {
- Cmd: []string{"rule", "create"},
- Err: tooFewArgsMsg + " " + ruleTriggerActionReqMsg,
- },
- common.InvalidArg {
- Cmd: []string{"rule", "create", "ruleName"},
- Err: tooFewArgsMsg + " " + ruleTriggerActionReqMsg,
- },
- common.InvalidArg {
- Cmd: []string{"rule", "create", "ruleName", "triggerName"},
- Err: tooFewArgsMsg + " " + ruleTriggerActionReqMsg,
- },
- common.InvalidArg {
- Cmd: []string{"rule", "create", "ruleName", "triggerName", "actionName", invalidArg},
- Err: tooManyArgsMsg + invalidArg + ".",
- },
+ {
+ Cmd: []string{"activation", "result"},
+ Err: tooFewArgsMsg + " " + activationIdReq,
+ },
+ {
+ Cmd: []string{"activation", "result", "activationID", invalidArg},
+ Err: tooManyArgsMsg + invalidArg + ".",
+ },
+ {
+ Cmd: []string{"activation", "poll", "activationID", invalidArg},
+ Err: tooManyArgsMsg + invalidArg + ". " + optNamespaceMsg,
+ },
+ {
+ Cmd: []string{"namespace", "list", invalidArg},
+ Err: tooManyArgsMsg + invalidArg + ". " + noArgsReqMsg,
+ },
+ {
+ Cmd: []string{"namespace", "get", invalidArg},
+ Err: tooManyArgsMsg + invalidArg + ". " + noArgsReqMsg,
+ },
+ {
+ Cmd: []string{"package", "create"},
+ Err: tooFewArgsMsg + " " + packageNameReqMsg,
+ },
+ {
+ Cmd: []string{"package", "create", "packageName", invalidArg},
+ Err: tooManyArgsMsg + invalidArg + ".",
+ },
+ {
+ Cmd: []string{"package", "create", "packageName", "--shared", invalidArg},
+ Err: invalidShared,
+ },
+ {
+ Cmd: []string{"package", "update"},
+ Err: tooFewArgsMsg + " " + packageNameReqMsg,
+ },
+ {
+ Cmd: []string{"package", "update", "packageName", invalidArg},
+ Err: tooManyArgsMsg + invalidArg + ".",
+ },
+ {
+ Cmd: []string{"package", "update", "packageName", "--shared", invalidArg},
+ Err: invalidShared,
+ },
+ {
+ Cmd: []string{"package", "get"},
+ Err: tooFewArgsMsg + " " + packageNameReqMsg,
+ },
+ {
+ Cmd: []string{"package", "get", "packageName", "namespace", invalidArg},
+ Err: tooManyArgsMsg + invalidArg + ".",
+ },
+ {
+ Cmd: []string{"package", "bind"},
+ Err: tooFewArgsMsg + " " + packageNameBindingReqMsg,
+ },
+ {
+ Cmd: []string{"package", "bind", "packageName"},
+ Err: tooFewArgsMsg + " " + packageNameBindingReqMsg,
+ },
+ {
+ Cmd: []string{"package", "bind", "packageName", "bindingName", invalidArg},
+ Err: tooManyArgsMsg + invalidArg + ".",
+ },
+ {
+ Cmd: []string{"package", "list", "namespace", invalidArg},
+ Err: tooManyArgsMsg + invalidArg + ". " + optNamespaceMsg,
+ },
+ {
+ Cmd: []string{"package", "delete"},
+ Err: tooFewArgsMsg + " " + packageNameReqMsg,
+ },
+ {
+ Cmd: []string{"package", "delete", "namespace", invalidArg},
+ Err: tooManyArgsMsg + invalidArg + ".",
+ },
+ {
+ Cmd: []string{"package", "refresh", "namespace", invalidArg},
+ Err: tooManyArgsMsg + invalidArg + ". " + optNamespaceMsg,
+ },
+ {
+ Cmd: []string{"rule", "enable"},
+ Err: tooFewArgsMsg + " " + ruleNameReqMsg,
+ },
+ {
+ Cmd: []string{"rule", "enable", "ruleName", invalidArg},
+ Err: tooManyArgsMsg + invalidArg + ".",
+ },
+ {
+ Cmd: []string{"rule", "disable"},
+ Err: tooFewArgsMsg + " " + ruleNameReqMsg,
+ },
+ {
+ Cmd: []string{"rule", "disable", "ruleName", invalidArg},
+ Err: tooManyArgsMsg + invalidArg + ".",
+ },
+ {
+ Cmd: []string{"rule", "status"},
+ Err: tooFewArgsMsg + " " + ruleNameReqMsg,
+ },
+ {
+ Cmd: []string{"rule", "status", "ruleName", invalidArg},
+ Err: tooManyArgsMsg + invalidArg + ".",
+ },
+ {
+ Cmd: []string{"rule", "create"},
+ Err: tooFewArgsMsg + " " + ruleTriggerActionReqMsg,
+ },
+ {
+ Cmd: []string{"rule", "create", "ruleName"},
+ Err: tooFewArgsMsg + " " + ruleTriggerActionReqMsg,
+ },
+ {
+ Cmd: []string{"rule", "create", "ruleName", "triggerName"},
+ Err: tooFewArgsMsg + " " + ruleTriggerActionReqMsg,
+ },
+ {
+ Cmd: []string{"rule", "create", "ruleName", "triggerName", "actionName", invalidArg},
+ Err: tooManyArgsMsg + invalidArg + ".",
+ },
- common.InvalidArg {
- Cmd: []string{"rule", "update"},
- Err: tooFewArgsMsg + " " + ruleTriggerActionReqMsg,
- },
- common.InvalidArg {
- Cmd: []string{"rule", "update", "ruleName"},
- Err: tooFewArgsMsg + " " + ruleTriggerActionReqMsg,
- },
- common.InvalidArg {
- Cmd: []string{"rule", "update", "ruleName", "triggerName"},
- Err: tooFewArgsMsg + " " + ruleTriggerActionReqMsg,
- },
- common.InvalidArg {
- Cmd: []string{"rule", "update", "ruleName", "triggerName", "actionName", invalidArg},
- Err: tooManyArgsMsg + invalidArg + ".",
- },
- common.InvalidArg {
- Cmd: []string{"rule", "get"},
- Err: tooFewArgsMsg + " " + ruleNameReqMsg,
- },
- common.InvalidArg {
- Cmd: []string{"rule", "get", "ruleName", "namespace", invalidArg},
- Err: tooManyArgsMsg + invalidArg + ".",
- },
- common.InvalidArg {
- Cmd: []string{"rule", "delete"},
- Err: tooFewArgsMsg + " " + ruleNameReqMsg,
- },
- common.InvalidArg {
- Cmd: []string{"rule", "delete", "ruleName", invalidArg},
- Err: tooManyArgsMsg + invalidArg + ".",
- },
- common.InvalidArg {
- Cmd: []string{"rule", "list", "namespace", invalidArg},
- Err: tooManyArgsMsg + invalidArg + ". " + optNamespaceMsg,
- },
+ {
+ Cmd: []string{"rule", "update"},
+ Err: tooFewArgsMsg + " " + ruleTriggerActionReqMsg,
+ },
+ {
+ Cmd: []string{"rule", "update", "ruleName"},
+ Err: tooFewArgsMsg + " " + ruleTriggerActionReqMsg,
+ },
+ {
+ Cmd: []string{"rule", "update", "ruleName", "triggerName"},
+ Err: tooFewArgsMsg + " " + ruleTriggerActionReqMsg,
+ },
+ {
+ Cmd: []string{"rule", "update", "ruleName", "triggerName", "actionName", invalidArg},
+ Err: tooManyArgsMsg + invalidArg + ".",
+ },
+ {
+ Cmd: []string{"rule", "get"},
+ Err: tooFewArgsMsg + " " + ruleNameReqMsg,
+ },
+ {
+ Cmd: []string{"rule", "get", "ruleName", "namespace", invalidArg},
+ Err: tooManyArgsMsg + invalidArg + ".",
+ },
+ {
+ Cmd: []string{"rule", "delete"},
+ Err: tooFewArgsMsg + " " + ruleNameReqMsg,
+ },
+ {
+ Cmd: []string{"rule", "delete", "ruleName", invalidArg},
+ Err: tooManyArgsMsg + invalidArg + ".",
+ },
+ {
+ Cmd: []string{"rule", "list", "namespace", invalidArg},
+ Err: tooManyArgsMsg + invalidArg + ". " + optNamespaceMsg,
+ },
- common.InvalidArg {
- Cmd: []string{"trigger", "fire"},
- Err: tooFewArgsMsg + " " + triggerNameReqMsg + " " + optPayloadMsg,
- },
- common.InvalidArg {
- Cmd: []string{"trigger", "fire", "triggerName", "triggerPayload", invalidArg},
- Err: tooManyArgsMsg + invalidArg + ". " + triggerNameReqMsg + " " +optPayloadMsg,
- },
- common.InvalidArg {
- Cmd: []string{"trigger", "create"},
- Err: tooFewArgsMsg + " " + triggerNameReqMsg,
- },
- common.InvalidArg {
- Cmd: []string{"trigger", "create", "triggerName", invalidArg},
- Err: tooManyArgsMsg + invalidArg + ".",
- },
- common.InvalidArg {
- Cmd: []string{"trigger", "update"},
- Err: tooFewArgsMsg + " " + triggerNameReqMsg,
- },
- common.InvalidArg {
- Cmd: []string{"trigger", "update", "triggerName", invalidArg},
- Err: tooManyArgsMsg + invalidArg + ".",
- },
+ {
+ Cmd: []string{"trigger", "fire"},
+ Err: tooFewArgsMsg + " " + triggerNameReqMsg + " " + optPayloadMsg,
+ },
+ {
+ Cmd: []string{"trigger", "fire", "triggerName", "triggerPayload", invalidArg},
+ Err: tooManyArgsMsg + invalidArg + ". " + triggerNameReqMsg + " " + optPayloadMsg,
+ },
+ {
+ Cmd: []string{"trigger", "create"},
+ Err: tooFewArgsMsg + " " + triggerNameReqMsg,
+ },
+ {
+ Cmd: []string{"trigger", "create", "triggerName", invalidArg},
+ Err: tooManyArgsMsg + invalidArg + ".",
+ },
+ {
+ Cmd: []string{"trigger", "update"},
+ Err: tooFewArgsMsg + " " + triggerNameReqMsg,
+ },
+ {
+ Cmd: []string{"trigger", "update", "triggerName", invalidArg},
+ Err: tooManyArgsMsg + invalidArg + ".",
+ },
- common.InvalidArg {
- Cmd: []string{"trigger", "get"},
- Err: tooFewArgsMsg + " " + triggerNameReqMsg,
- },
- common.InvalidArg {
- Cmd: []string{"trigger", "get", "triggerName", "namespace", invalidArg},
- Err: tooManyArgsMsg + invalidArg + ".",
- },
- common.InvalidArg {
- Cmd: []string{"trigger", "delete"},
- Err: tooFewArgsMsg + " " + triggerNameReqMsg,
- },
- common.InvalidArg {
- Cmd: []string{"trigger", "delete", "triggerName", invalidArg},
- Err: tooManyArgsMsg + invalidArg + ".",
- },
- common.InvalidArg {
- Cmd: []string{"trigger", "list", "namespace", invalidArg},
- Err: tooManyArgsMsg + invalidArg + ". " + optNamespaceMsg,
- },
- }
+ {
+ Cmd: []string{"trigger", "get"},
+ Err: tooFewArgsMsg + " " + triggerNameReqMsg,
+ },
+ {
+ Cmd: []string{"trigger", "get", "triggerName", "namespace", invalidArg},
+ Err: tooManyArgsMsg + invalidArg + ".",
+ },
+ {
+ Cmd: []string{"trigger", "delete"},
+ Err: tooFewArgsMsg + " " + triggerNameReqMsg,
+ },
+ {
+ Cmd: []string{"trigger", "delete", "triggerName", invalidArg},
+ Err: tooManyArgsMsg + invalidArg + ".",
+ },
+ {
+ Cmd: []string{"trigger", "list", "namespace", invalidArg},
+ Err: tooManyArgsMsg + invalidArg + ". " + optNamespaceMsg,
+ },
+ }
}
var wsk *common.Wsk = common.NewWsk()
@@ -333,262 +333,262 @@ var tmpProp = common.GetRepoPath() + "/wskprops.tmp"
// Test case to set apihost, auth, and namespace.
func TestSetAPIHostAuthNamespace(t *testing.T) {
- common.CreateFile(tmpProp)
- common.WriteFile(tmpProp, []string{})
+ common.CreateFile(tmpProp)
+ common.WriteFile(tmpProp, []string{})
- os.Setenv("WSK_CONFIG_FILE", tmpProp)
- assert.Equal(t, os.Getenv("WSK_CONFIG_FILE"), tmpProp, "The environment variable WSK_CONFIG_FILE has not been set.")
+ os.Setenv("WSK_CONFIG_FILE", tmpProp)
+ assert.Equal(t, os.Getenv("WSK_CONFIG_FILE"), tmpProp, "The environment variable WSK_CONFIG_FILE has not been set.")
- namespace, _ := wsk.ListNamespaces()
- namespaces := strings.Split(strings.TrimSpace(string(namespace)), "\n")
- expectedNamespace := string(namespaces[len(namespaces) - 1])
- fmt.Println(wsk.Wskprops.APIHost)
- if (wsk.Wskprops.APIHost != "" && wsk.Wskprops.APIHost != "") {
- stdout, err := wsk.RunCommand("property", "set", "--apihost", wsk.Wskprops.APIHost,
- "--auth", wsk.Wskprops.AuthKey, "--namespace", expectedNamespace)
- ouputString := string(stdout)
- assert.Equal(t, nil, err, "The command property set --apihost --auth --namespace failed to run.")
- assert.Contains(t, ouputString, "ok: whisk auth set. Run 'wsk property get --auth' to see the new value.",
- "The output of the command property set --apihost --auth --namespace does not contain \"whisk auth set\".")
- assert.Contains(t, ouputString, "ok: whisk API host set to " + wsk.Wskprops.APIHost,
- "The output of the command property set --apihost --auth --namespace does not contain \"whisk API host set\".")
- assert.Contains(t, ouputString, "ok: whisk namespace set to " + expectedNamespace,
- "The output of the command property set --apihost --auth --namespace does not contain \"whisk namespace set\".")
- }
- common.DeleteFile(tmpProp)
+ namespace, _ := wsk.ListNamespaces()
+ namespaces := strings.Split(strings.TrimSpace(string(namespace)), "\n")
+ expectedNamespace := string(namespaces[len(namespaces)-1])
+ fmt.Println(wsk.Wskprops.APIHost)
+ if wsk.Wskprops.APIHost != "" && wsk.Wskprops.APIHost != "" {
+ stdout, err := wsk.RunCommand("property", "set", "--apihost", wsk.Wskprops.APIHost,
+ "--auth", wsk.Wskprops.AuthKey, "--namespace", expectedNamespace)
+ ouputString := string(stdout)
+ assert.Equal(t, nil, err, "The command property set --apihost --auth --namespace failed to run.")
+ assert.Contains(t, ouputString, "ok: whisk auth set. Run 'wsk property get --auth' to see the new value.",
+ "The output of the command property set --apihost --auth --namespace does not contain \"whisk auth set\".")
+ assert.Contains(t, ouputString, "ok: whisk API host set to "+wsk.Wskprops.APIHost,
+ "The output of the command property set --apihost --auth --namespace does not contain \"whisk API host set\".")
+ assert.Contains(t, ouputString, "ok: whisk namespace set to "+expectedNamespace,
+ "The output of the command property set --apihost --auth --namespace does not contain \"whisk namespace set\".")
+ }
+ common.DeleteFile(tmpProp)
}
// Test case to show api build version using property file.
func TestShowAPIBuildVersion(t *testing.T) {
- common.CreateFile(tmpProp)
+ common.CreateFile(tmpProp)
- os.Setenv("WSK_CONFIG_FILE", tmpProp)
- assert.Equal(t, os.Getenv("WSK_CONFIG_FILE"), tmpProp, "The environment variable WSK_CONFIG_FILE has not been set.")
+ os.Setenv("WSK_CONFIG_FILE", tmpProp)
+ assert.Equal(t, os.Getenv("WSK_CONFIG_FILE"), tmpProp, "The environment variable WSK_CONFIG_FILE has not been set.")
- stdout, err := wsk.RunCommand("property", "set", "--apihost", wsk.Wskprops.APIHost,
- "--apiversion", wsk.Wskprops.Apiversion)
- assert.Equal(t, nil, err, "The command property set --apihost --apiversion failed to run.")
- stdout, err = wsk.RunCommand("property", "get", "-i", "--apibuild")
- assert.Equal(t, nil, err, "The command property get -i --apibuild failed to run.")
- println(common.RemoveRedundentSpaces(string(stdout)))
- assert.NotContains(t, common.RemoveRedundentSpaces(string(stdout)), "whisk API build Unknown",
- "The output of the command property get --apibuild does not contain \"whisk API build Unknown\".")
- assert.NotContains(t, common.RemoveRedundentSpaces(string(stdout)), "Unable to obtain API build information",
- "The output of the command property get --apibuild does not contain \"Unable to obtain API build information\".")
- assert.Contains(t, common.RemoveRedundentSpaces(string(stdout)), "whisk API build 20",
- "The output of the command property get --apibuild does not contain \"whisk API build 20\".")
- common.DeleteFile(tmpProp)
+ stdout, err := wsk.RunCommand("property", "set", "--apihost", wsk.Wskprops.APIHost,
+ "--apiversion", wsk.Wskprops.Apiversion)
+ assert.Equal(t, nil, err, "The command property set --apihost --apiversion failed to run.")
+ stdout, err = wsk.RunCommand("property", "get", "-i", "--apibuild")
+ assert.Equal(t, nil, err, "The command property get -i --apibuild failed to run.")
+ println(common.RemoveRedundentSpaces(string(stdout)))
+ assert.NotContains(t, common.RemoveRedundentSpaces(string(stdout)), "whisk API build Unknown",
+ "The output of the command property get --apibuild does not contain \"whisk API build Unknown\".")
+ assert.NotContains(t, common.RemoveRedundentSpaces(string(stdout)), "Unable to obtain API build information",
+ "The output of the command property get --apibuild does not contain \"Unable to obtain API build information\".")
+ assert.Contains(t, common.RemoveRedundentSpaces(string(stdout)), "whisk API build 20",
+ "The output of the command property get --apibuild does not contain \"whisk API build 20\".")
+ common.DeleteFile(tmpProp)
}
// Test case to fail to show api build when setting apihost to bogus value.
func TestFailShowAPIBuildVersion(t *testing.T) {
- common.CreateFile(tmpProp)
+ common.CreateFile(tmpProp)
- os.Setenv("WSK_CONFIG_FILE", tmpProp)
- assert.Equal(t, os.Getenv("WSK_CONFIG_FILE"), tmpProp, "The environment variable WSK_CONFIG_FILE has not been set.")
+ os.Setenv("WSK_CONFIG_FILE", tmpProp)
+ assert.Equal(t, os.Getenv("WSK_CONFIG_FILE"), tmpProp, "The environment variable WSK_CONFIG_FILE has not been set.")
- _, err := wsk.RunCommand("property", "set", "--apihost", "xxxx.yyyy")
- assert.Equal(t, nil, err, "The command property set --apihost failed to run.")
- stdout, err := wsk.RunCommand("property", "get", "-i", "--apibuild")
- assert.NotEqual(t, nil, err, "The command property get -i --apibuild does not raise any error.")
- assert.Contains(t, common.RemoveRedundentSpaces(string(stdout)), "whisk API build Unknown",
- "The output of the command property get --apibuild does not contain \"whisk API build Unknown\".")
- assert.Contains(t, common.RemoveRedundentSpaces(string(stdout)), "Unable to obtain API build information",
- "The output of the command property get --apibuild does not contain \"Unable to obtain API build information\".")
+ _, err := wsk.RunCommand("property", "set", "--apihost", "xxxx.yyyy")
+ assert.Equal(t, nil, err, "The command property set --apihost failed to run.")
+ stdout, err := wsk.RunCommand("property", "get", "-i", "--apibuild")
+ assert.NotEqual(t, nil, err, "The command property get -i --apibuild does not raise any error.")
+ assert.Contains(t, common.RemoveRedundentSpaces(string(stdout)), "whisk API build Unknown",
+ "The output of the command property get --apibuild does not contain \"whisk API build Unknown\".")
+ assert.Contains(t, common.RemoveRedundentSpaces(string(stdout)), "Unable to obtain API build information",
+ "The output of the command property get --apibuild does not contain \"Unable to obtain API build information\".")
}
// Test case to show api build using http apihost.
func TestShowAPIBuildVersionHTTP(t *testing.T) {
- common.CreateFile(tmpProp)
+ common.CreateFile(tmpProp)
- os.Setenv("WSK_CONFIG_FILE", tmpProp)
- assert.Equal(t, os.Getenv("WSK_CONFIG_FILE"), tmpProp, "The environment variable WSK_CONFIG_FILE has not been set.")
+ os.Setenv("WSK_CONFIG_FILE", tmpProp)
+ assert.Equal(t, os.Getenv("WSK_CONFIG_FILE"), tmpProp, "The environment variable WSK_CONFIG_FILE has not been set.")
- apihost := wsk.Wskprops.APIHost
- stdout, err := wsk.RunCommand("property", "set", "--apihost", apihost)
- assert.Equal(t, nil, err, "The command property set --apihost failed to run.")
- stdout, err = wsk.RunCommand("property", "get", "-i", "--apibuild")
- println(common.RemoveRedundentSpaces(string(stdout)))
- //assert.Equal(t, nil, err, "The command property get -i --apibuild failed to run.")
- assert.NotContains(t, common.RemoveRedundentSpaces(string(stdout)), "whisk API build Unknown",
- "The output of the command property get --apibuild does not contain \"whisk API build Unknown\".")
- assert.NotContains(t, common.RemoveRedundentSpaces(string(stdout)), "Unable to obtain API build information",
- "The output of the command property get --apibuild does not contain \"Unable to obtain API build information\".")
- assert.Contains(t, common.RemoveRedundentSpaces(string(stdout)), "whisk API build 20",
- "The output of the command property get --apibuild does not contain \"whisk API build 20\".")
- common.DeleteFile(tmpProp)
+ apihost := wsk.Wskprops.APIHost
+ stdout, err := wsk.RunCommand("property", "set", "--apihost", apihost)
+ assert.Equal(t, nil, err, "The command property set --apihost failed to run.")
+ stdout, err = wsk.RunCommand("property", "get", "-i", "--apibuild")
+ println(common.RemoveRedundentSpaces(string(stdout)))
+ //assert.Equal(t, nil, err, "The command property get -i --apibuild failed to run.")
+ assert.NotContains(t, common.RemoveRedundentSpaces(string(stdout)), "whisk API build Unknown",
+ "The output of the command property get --apibuild does not contain \"whisk API build Unknown\".")
+ assert.NotContains(t, common.RemoveRedundentSpaces(string(stdout)), "Unable to obtain API build information",
+ "The output of the command property get --apibuild does not contain \"Unable to obtain API build information\".")
+ assert.Contains(t, common.RemoveRedundentSpaces(string(stdout)), "whisk API build 20",
+ "The output of the command property get --apibuild does not contain \"whisk API build 20\".")
+ common.DeleteFile(tmpProp)
}
// Test case to reject bad command.
func TestRejectAuthCommNoKey(t *testing.T) {
- common.CreateFile(tmpProp)
+ common.CreateFile(tmpProp)
- os.Setenv("WSK_CONFIG_FILE", tmpProp)
- assert.Equal(t, os.Getenv("WSK_CONFIG_FILE"), tmpProp, "The environment variable WSK_CONFIG_FILE has not been set.")
+ os.Setenv("WSK_CONFIG_FILE", tmpProp)
+ assert.Equal(t, os.Getenv("WSK_CONFIG_FILE"), tmpProp, "The environment variable WSK_CONFIG_FILE has not been set.")
- stdout, err := wsk.RunCommand("list", "--apihost", wsk.Wskprops.APIHost,
- "--apiversion", wsk.Wskprops.Apiversion)
- assert.NotEqual(t, nil, err, "The command list should fail to run.")
- assert.Contains(t, common.RemoveRedundentSpaces(string(stdout)), "usage.",
- "The output of the command does not contain \"usage.\".")
- assert.Contains(t, common.RemoveRedundentSpaces(string(stdout)), "--auth is required",
- "The output of the command does not contain \"--auth is required\".")
- common.DeleteFile(tmpProp)
+ stdout, err := wsk.RunCommand("list", "--apihost", wsk.Wskprops.APIHost,
+ "--apiversion", wsk.Wskprops.Apiversion)
+ assert.NotEqual(t, nil, err, "The command list should fail to run.")
+ assert.Contains(t, common.RemoveRedundentSpaces(string(stdout)), "usage.",
+ "The output of the command does not contain \"usage.\".")
+ assert.Contains(t, common.RemoveRedundentSpaces(string(stdout)), "--auth is required",
+ "The output of the command does not contain \"--auth is required\".")
+ common.DeleteFile(tmpProp)
}
// Test case to reject commands that are executed with invalid arguments.
func TestRejectCommInvalidArgs(t *testing.T) {
- initInvalidArgs()
- for _, invalidArg := range invalidArgs {
- cs := invalidArg.Cmd
- cs = append(cs, "--apihost", wsk.Wskprops.APIHost)
- stdout, err := wsk.RunCommand(cs...)
- outputString := string(stdout)
- assert.NotEqual(t, nil, err, "The command should fail to run.")
- if (err.Error() == "exit status 1") {
- assert.Equal(t, "exit status 1", err.Error(), "The error should be exit status 1 or 2.")
- } else {
- assert.Equal(t, "exit status 2", err.Error(), "The error should be exit status 1 or 2.")
- }
- assert.Contains(t, outputString, invalidArg.Err,
- "The output of the command does not contain " + invalidArg.Err)
- assert.Contains(t, outputString, "Run 'wsk --help' for usage",
- "The output of the command does not contain \"Run 'wsk --help' for usage\".")
- }
+ initInvalidArgs()
+ for _, invalidArg := range invalidArgs {
+ cs := invalidArg.Cmd
+ cs = append(cs, "--apihost", wsk.Wskprops.APIHost)
+ stdout, err := wsk.RunCommand(cs...)
+ outputString := string(stdout)
+ assert.NotEqual(t, nil, err, "The command should fail to run.")
+ if err.Error() == "exit status 1" {
+ assert.Equal(t, "exit status 1", err.Error(), "The error should be exit status 1 or 2.")
+ } else {
+ assert.Equal(t, "exit status 2", err.Error(), "The error should be exit status 1 or 2.")
+ }
+ assert.Contains(t, outputString, invalidArg.Err,
+ "The output of the command does not contain "+invalidArg.Err)
+ assert.Contains(t, outputString, "Run 'wsk --help' for usage",
+ "The output of the command does not contain \"Run 'wsk --help' for usage\".")
+ }
}
// Test case to reject commands that are executed with invalid JSON for annotations and parameters.
func TestRejectCommInvalidJSON(t *testing.T) {
- helloFile := common.GetTestActionFilename("hello.js")
- var invalidJSONInputs = []string{
- "{\"invalid1\": }",
- "{\"invalid2\": bogus}",
- "{\"invalid1\": \"aKey\"",
- "invalid \"string\"",
- "{\"invalid1\": [1, 2, \"invalid\"\"arr\"]}",
- }
- var invalidJSONFiles = []string{
- common.GetTestActionFilename("malformed.js"),
- common.GetTestActionFilename("invalidInput1.json"),
- common.GetTestActionFilename("invalidInput2.json"),
- common.GetTestActionFilename("invalidInput3.json"),
- common.GetTestActionFilename("invalidInput4.json"),
- }
- var invalidParamArg = "Invalid parameter argument"
- var invalidAnnoArg = "Invalid annotation argument"
- var paramCmds = []common.InvalidArg{
- common.InvalidArg{
- Cmd: []string{"action", "create", "actionName", helloFile},
- Err: invalidParamArg,
- },
- common.InvalidArg{
- Cmd: []string{"action", "update", "actionName", helloFile},
- Err: invalidParamArg,
- },
- common.InvalidArg{
- Cmd: []string{"action", "invoke", "actionName"},
- Err: invalidParamArg,
- },
- common.InvalidArg{
- Cmd: []string{"package", "create", "packageName"},
- Err: invalidParamArg,
- },
- common.InvalidArg{
- Cmd: []string{"package", "update", "packageName"},
- Err: invalidParamArg,
- },
- common.InvalidArg{
- Cmd: []string{"package", "bind", "packageName", "boundPackageName"},
- Err: invalidParamArg,
- },
- common.InvalidArg{
- Cmd: []string{"trigger", "create", "triggerName"},
- Err: invalidParamArg,
- },
- common.InvalidArg{
- Cmd: []string{"trigger", "update", "triggerName"},
- Err: invalidParamArg,
- },
- common.InvalidArg{
- Cmd: []string{"trigger", "fire", "triggerName"},
- Err: invalidParamArg,
- },
- }
+ helloFile := common.GetTestActionFilename("hello.js")
+ var invalidJSONInputs = []string{
+ "{\"invalid1\": }",
+ "{\"invalid2\": bogus}",
+ "{\"invalid1\": \"aKey\"",
+ "invalid \"string\"",
+ "{\"invalid1\": [1, 2, \"invalid\"\"arr\"]}",
+ }
+ var invalidJSONFiles = []string{
+ common.GetTestActionFilename("malformed.js"),
+ common.GetTestActionFilename("invalidInput1.json"),
+ common.GetTestActionFilename("invalidInput2.json"),
+ common.GetTestActionFilename("invalidInput3.json"),
+ common.GetTestActionFilename("invalidInput4.json"),
+ }
+ var invalidParamArg = "Invalid parameter argument"
+ var invalidAnnoArg = "Invalid annotation argument"
+ var paramCmds = []common.InvalidArg{
+ {
+ Cmd: []string{"action", "create", "actionName", helloFile},
+ Err: invalidParamArg,
+ },
+ {
+ Cmd: []string{"action", "update", "actionName", helloFile},
+ Err: invalidParamArg,
+ },
+ {
+ Cmd: []string{"action", "invoke", "actionName"},
+ Err: invalidParamArg,
+ },
+ {
+ Cmd: []string{"package", "create", "packageName"},
+ Err: invalidParamArg,
+ },
+ {
+ Cmd: []string{"package", "update", "packageName"},
+ Err: invalidParamArg,
+ },
+ {
+ Cmd: []string{"package", "bind", "packageName", "boundPackageName"},
+ Err: invalidParamArg,
+ },
+ {
+ Cmd: []string{"trigger", "create", "triggerName"},
+ Err: invalidParamArg,
+ },
+ {
+ Cmd: []string{"trigger", "update", "triggerName"},
+ Err: invalidParamArg,
+ },
+ {
+ Cmd: []string{"trigger", "fire", "triggerName"},
+ Err: invalidParamArg,
+ },
+ }
- var annotCmds = []common.InvalidArg{
- common.InvalidArg{
- Cmd: []string{"action", "create", "actionName", helloFile},
- Err: invalidAnnoArg,
- },
- common.InvalidArg{
- Cmd: []string{"action", "update", "actionName", helloFile},
- Err: invalidAnnoArg,
- },
- common.InvalidArg{
- Cmd: []string{"package", "create", "packageName"},
- Err: invalidAnnoArg,
- },
- common.InvalidArg{
- Cmd: []string{"package", "update", "packageName"},
- Err: invalidAnnoArg,
- },
- common.InvalidArg{
- Cmd: []string{"package", "bind", "packageName", "boundPackageName"},
- Err: invalidAnnoArg,
- },
- common.InvalidArg{
- Cmd: []string{"trigger", "create", "triggerName"},
- Err: invalidAnnoArg,
- },
- common.InvalidArg{
- Cmd: []string{"trigger", "update", "triggerName"},
- Err: invalidAnnoArg,
- },
- }
+ var annotCmds = []common.InvalidArg{
+ {
+ Cmd: []string{"action", "create", "actionName", helloFile},
+ Err: invalidAnnoArg,
+ },
+ {
+ Cmd: []string{"action", "update", "actionName", helloFile},
+ Err: invalidAnnoArg,
+ },
+ {
+ Cmd: []string{"package", "create", "packageName"},
+ Err: invalidAnnoArg,
+ },
+ {
+ Cmd: []string{"package", "update", "packageName"},
+ Err: invalidAnnoArg,
+ },
+ {
+ Cmd: []string{"package", "bind", "packageName", "boundPackageName"},
+ Err: invalidAnnoArg,
+ },
+ {
+ Cmd: []string{"trigger", "create", "triggerName"},
+ Err: invalidAnnoArg,
+ },
+ {
+ Cmd: []string{"trigger", "update", "triggerName"},
+ Err: invalidAnnoArg,
+ },
+ }
- for _, cmd := range paramCmds {
- for _, invalid := range invalidJSONInputs {
- cs := cmd.Cmd
- cs = append(cs, "-p", "key", invalid, "--apihost", wsk.Wskprops.APIHost)
- stdout, err := wsk.RunCommand(cs...)
- outputString := string(stdout)
- assert.NotEqual(t, nil, err, "The command should fail to run.")
- assert.Equal(t, "exit status 1", err.Error(), "The error should be exit status 1.")
- assert.Contains(t, outputString, cmd.Err,
- "The output of the command does not contain " + cmd.Err + " .")
- }
- for _, invalid := range invalidJSONFiles {
- cs := cmd.Cmd
- cs = append(cs, "-P", invalid, "--apihost", wsk.Wskprops.APIHost)
- stdout, err := wsk.RunCommand(cs...)
- outputString := string(stdout)
- assert.NotEqual(t, nil, err, "The command should fail to run.")
- assert.Equal(t, "exit status 1", err.Error(), "The error should be exit status 1.")
- assert.Contains(t, outputString, cmd.Err,
- "The output of the command does not contain " + cmd.Err + " .")
- }
- }
+ for _, cmd := range paramCmds {
+ for _, invalid := range invalidJSONInputs {
+ cs := cmd.Cmd
+ cs = append(cs, "-p", "key", invalid, "--apihost", wsk.Wskprops.APIHost)
+ stdout, err := wsk.RunCommand(cs...)
+ outputString := string(stdout)
+ assert.NotEqual(t, nil, err, "The command should fail to run.")
+ assert.Equal(t, "exit status 1", err.Error(), "The error should be exit status 1.")
+ assert.Contains(t, outputString, cmd.Err,
+ "The output of the command does not contain "+cmd.Err+" .")
+ }
+ for _, invalid := range invalidJSONFiles {
+ cs := cmd.Cmd
+ cs = append(cs, "-P", invalid, "--apihost", wsk.Wskprops.APIHost)
+ stdout, err := wsk.RunCommand(cs...)
+ outputString := string(stdout)
+ assert.NotEqual(t, nil, err, "The command should fail to run.")
+ assert.Equal(t, "exit status 1", err.Error(), "The error should be exit status 1.")
+ assert.Contains(t, outputString, cmd.Err,
+ "The output of the command does not contain "+cmd.Err+" .")
+ }
+ }
- for _, cmd := range annotCmds {
- for _, invalid := range invalidJSONInputs {
- cs := cmd.Cmd
- cs = append(cs, "-a", "key", invalid, "--apihost", wsk.Wskprops.APIHost)
- stdout, err := wsk.RunCommand(cs...)
- outputString := string(stdout)
- assert.NotEqual(t, nil, err, "The command should fail to run.")
- assert.Equal(t, "exit status 1", err.Error(), "The error should be exit status 1.")
- assert.Contains(t, outputString, cmd.Err,
- "The output of the command does not contain " + cmd.Err + " .")
- }
- for _, invalid := range invalidJSONFiles {
- cs := cmd.Cmd
- cs = append(cs, "-A", invalid, "--apihost", wsk.Wskprops.APIHost)
- stdout, err := wsk.RunCommand(cs...)
- outputString := string(stdout)
- assert.NotEqual(t, nil, err, "The command should fail to run.")
- assert.Equal(t, "exit status 1", err.Error(), "The error should be exit status 1.")
- assert.Contains(t, outputString, cmd.Err,
- "The output of the command does not contain " + cmd.Err + " .")
- }
- }
+ for _, cmd := range annotCmds {
+ for _, invalid := range invalidJSONInputs {
+ cs := cmd.Cmd
+ cs = append(cs, "-a", "key", invalid, "--apihost", wsk.Wskprops.APIHost)
+ stdout, err := wsk.RunCommand(cs...)
+ outputString := string(stdout)
+ assert.NotEqual(t, nil, err, "The command should fail to run.")
+ assert.Equal(t, "exit status 1", err.Error(), "The error should be exit status 1.")
+ assert.Contains(t, outputString, cmd.Err,
+ "The output of the command does not contain "+cmd.Err+" .")
+ }
+ for _, invalid := range invalidJSONFiles {
+ cs := cmd.Cmd
+ cs = append(cs, "-A", invalid, "--apihost", wsk.Wskprops.APIHost)
+ stdout, err := wsk.RunCommand(cs...)
+ outputString := string(stdout)
+ assert.NotEqual(t, nil, err, "The command should fail to run.")
+ assert.Equal(t, "exit status 1", err.Error(), "The error should be exit status 1.")
+ assert.Contains(t, outputString, cmd.Err,
+ "The output of the command does not contain "+cmd.Err+" .")
+ }
+ }
}
diff --git a/wski18n/detection.go b/wski18n/detection.go
index b442cc4..c3866dd 100644
--- a/wski18n/detection.go
+++ b/wski18n/detection.go
@@ -20,24 +20,24 @@ package wski18n
import "github.com/cloudfoundry/jibber_jabber"
type Detector interface {
- DetectLocale() string
- DetectLanguage() string
+ DetectLocale() string
+ DetectLanguage() string
}
type JibberJabberDetector struct{}
func (d *JibberJabberDetector) DetectLocale() string {
- userLocale, err := jibber_jabber.DetectIETF()
- if err != nil {
- userLocale = ""
- }
- return userLocale
+ userLocale, err := jibber_jabber.DetectIETF()
+ if err != nil {
+ userLocale = ""
+ }
+ return userLocale
}
func (d *JibberJabberDetector) DetectLanguage() string {
- lang, err := jibber_jabber.DetectLanguage()
- if err != nil {
- lang = ""
- }
- return lang
+ lang, err := jibber_jabber.DetectLanguage()
+ if err != nil {
+ lang = ""
+ }
+ return lang
}
diff --git a/wski18n/i18n.go b/wski18n/i18n.go
index 9991ac8..02a25d3 100644
--- a/wski18n/i18n.go
+++ b/wski18n/i18n.go
@@ -18,131 +18,131 @@
package wski18n
import (
- "path/filepath"
- "strings"
+ "path/filepath"
+ "strings"
- goi18n "github.com/nicksnyder/go-i18n/i18n"
+ goi18n "github.com/nicksnyder/go-i18n/i18n"
)
const (
- DEFAULT_LOCALE = "en_US"
+ DEFAULT_LOCALE = "en_US"
)
var SUPPORTED_LOCALES = []string{
- "de_DE",
- "en_US",
- "es_ES",
- "fr_FR",
- "it_IT",
- "ja_JA",
- "ko_KR",
- "pt_BR",
- "zh_Hans",
- "zh_Hant",
+ "de_DE",
+ "en_US",
+ "es_ES",
+ "fr_FR",
+ "it_IT",
+ "ja_JA",
+ "ko_KR",
+ "pt_BR",
+ "zh_Hans",
+ "zh_Hant",
}
var resourcePath = filepath.Join("wski18n", "resources")
func GetResourcePath() string {
- return resourcePath
+ return resourcePath
}
func SetResourcePath(path string) {
- resourcePath = path
+ resourcePath = path
}
var T goi18n.TranslateFunc
var curLocale string
func init() {
- curLocale = Init(new(JibberJabberDetector))
+ curLocale = Init(new(JibberJabberDetector))
}
func CurLocale() string {
- return curLocale
+ return curLocale
}
func Locale(detector Detector) string {
- // Use default locale until strings are translated
- /*sysLocale := normalize(detector.DetectLocale())
- if isSupported(sysLocale) {
- return sysLocale
- }
+ // Use default locale until strings are translated
+ /*sysLocale := normalize(detector.DetectLocale())
+ if isSupported(sysLocale) {
+ return sysLocale
+ }
- locale := defaultLocaleForLang(detector.DetectLanguage())
- if locale != "" {
- return locale
- }*/
+ locale := defaultLocaleForLang(detector.DetectLanguage())
+ if locale != "" {
+ return locale
+ }*/
- return DEFAULT_LOCALE
+ return DEFAULT_LOCALE
}
func Init(detector Detector) string {
- l := Locale(detector)
- InitWithLocale(l)
- return l
+ l := Locale(detector)
+ InitWithLocale(l)
+ return l
}
func InitWithLocale(locale string) {
- err := loadFromAsset(locale)
- if err != nil {
- panic(err)
- }
- T = goi18n.MustTfunc(locale)
+ err := loadFromAsset(locale)
+ if err != nil {
+ panic(err)
+ }
+ T = goi18n.MustTfunc(locale)
}
func loadFromAsset(locale string) (err error) {
- assetName := locale + ".all.json"
- assetKey := filepath.Join(resourcePath, assetName)
- bytes, err := Asset(assetKey)
- if err != nil {
- return
- }
- err = goi18n.ParseTranslationFileBytes(assetName, bytes)
- return
+ assetName := locale + ".all.json"
+ assetKey := filepath.Join(resourcePath, assetName)
+ bytes, err := Asset(assetKey)
+ if err != nil {
+ return
+ }
+ err = goi18n.ParseTranslationFileBytes(assetName, bytes)
+ return
}
func normalize(locale string) string {
- locale = strings.ToLower(strings.Replace(locale, "-", "_", 1))
- for _, l := range SUPPORTED_LOCALES {
- if strings.EqualFold(locale, l) {
- return l
- }
- }
- switch locale {
- case "zh_cn", "zh_sg":
- return "zh_Hans"
- case "zh_hk", "zh_tw":
- return "zh_Hant"
- }
- return locale
+ locale = strings.ToLower(strings.Replace(locale, "-", "_", 1))
+ for _, l := range SUPPORTED_LOCALES {
+ if strings.EqualFold(locale, l) {
+ return l
+ }
+ }
+ switch locale {
+ case "zh_cn", "zh_sg":
+ return "zh_Hans"
+ case "zh_hk", "zh_tw":
+ return "zh_Hant"
+ }
+ return locale
}
func isSupported(locale string) bool {
- for _, l := range SUPPORTED_LOCALES {
- if strings.EqualFold(locale, l) {
- return true
- }
- }
- return false
+ for _, l := range SUPPORTED_LOCALES {
+ if strings.EqualFold(locale, l) {
+ return true
+ }
+ }
+ return false
}
func defaultLocaleForLang(lang string) string {
- if lang != "" {
- lang = strings.ToLower(lang)
- for _, l := range SUPPORTED_LOCALES {
- if lang == LangOfLocale(l) {
- return l
- }
- }
- }
- return ""
+ if lang != "" {
+ lang = strings.ToLower(lang)
+ for _, l := range SUPPORTED_LOCALES {
+ if lang == LangOfLocale(l) {
+ return l
+ }
+ }
+ }
+ return ""
}
func LangOfLocale(locale string) string {
- if len(locale) < 2 {
- return ""
- }
- return locale[0:2]
+ if len(locale) < 2 {
+ return ""
+ }
+ return locale[0:2]
}
diff --git a/wski18n/i18n_resources.go b/wski18n/i18n_resources.go
index 6c0f431..bf3bbae 100644
--- a/wski18n/i18n_resources.go
+++ b/wski18n/i18n_resources.go
@@ -32,330 +32,330 @@
package wski18n
import (
- "bytes"
- "compress/gzip"
- "fmt"
- "io"
- "io/ioutil"
- "os"
- "path/filepath"
- "strings"
- "time"
+ "bytes"
+ "compress/gzip"
+ "fmt"
+ "io"
+ "io/ioutil"
+ "os"
+ "path/filepath"
+ "strings"
+ "time"
)
func bindataRead(data []byte, name string) ([]byte, error) {
- gz, err := gzip.NewReader(bytes.NewBuffer(data))
- if err != nil {
- return nil, fmt.Errorf("Read %q: %v", name, err)
- }
+ gz, err := gzip.NewReader(bytes.NewBuffer(data))
+ if err != nil {
+ return nil, fmt.Errorf("Read %q: %v", name, err)
+ }
- var buf bytes.Buffer
- _, err = io.Copy(&buf, gz)
- clErr := gz.Close()
+ var buf bytes.Buffer
+ _, err = io.Copy(&buf, gz)
+ clErr := gz.Close()
- if err != nil {
- return nil, fmt.Errorf("Read %q: %v", name, err)
- }
- if clErr != nil {
- return nil, err
- }
+ if err != nil {
+ return nil, fmt.Errorf("Read %q: %v", name, err)
+ }
+ if clErr != nil {
+ return nil, err
+ }
- return buf.Bytes(), nil
+ return buf.Bytes(), nil
}
type asset struct {
- bytes []byte
- info os.FileInfo
+ bytes []byte
+ info os.FileInfo
}
type bindataFileInfo struct {
- name string
- size int64
- mode os.FileMode
- modTime time.Time
+ name string
+ size int64
+ mode os.FileMode
+ modTime time.Time
}
func (fi bindataFileInfo) Name() string {
- return fi.name
+ return fi.name
}
func (fi bindataFileInfo) Size() int64 {
- return fi.size
+ return fi.size
}
func (fi bindataFileInfo) Mode() os.FileMode {
- return fi.mode
+ return fi.mode
}
func (fi bindataFileInfo) ModTime() time.Time {
- return fi.modTime
+ return fi.modTime
}
func (fi bindataFileInfo) IsDir() bool {
- return false
+ return false
}
func (fi bindataFileInfo) Sys() interface{} {
- return nil
+ return nil
}
var _wski18nResourcesDe_deAllJson = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x01\x00\x00\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00")
func wski18nResourcesDe_deAllJsonBytes() ([]byte, error) {
- return bindataRead(
- _wski18nResourcesDe_deAllJson,
- "wski18n/resources/de_DE.all.json",
- )
+ return bindataRead(
+ _wski18nResourcesDe_deAllJson,
+ "wski18n/resources/de_DE.all.json",
+ )
}
func wski18nResourcesDe_deAllJson() (*asset, error) {
- bytes, err := wski18nResourcesDe_deAllJsonBytes()
- if err != nil {
- return nil, err
- }
+ bytes, err := wski18nResourcesDe_deAllJsonBytes()
+ if err != nil {
+ return nil, err
+ }
- info := bindataFileInfo{name: "wski18n/resources/de_DE.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1510606284, 0)}
- a := &asset{bytes: bytes, info: info}
- return a, nil
+ info := bindataFileInfo{name: "wski18n/resources/de_DE.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1510606284, 0)}
+ a := &asset{bytes: bytes, info: info}
+ return a, nil
}
var _wski18nResourcesEn_usAllJson = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xcc\x5d\x4f\x73\xdb\x38\xb2\xbf\xcf\xa7\xe8\xca\xc5\xce\x2b\xd9\xd9\x3d\xbd\x7a\x49\xcd\x41\x13\x7b\x36\xde\x49\x6c\x57\xec\xcc\xee\xd4\x66\x6b\x04\x91\x90\x85\x35\x05\x70\x00\xd0\xb2\x92\xf1\x77\x7f\x05\x80\xa4\x48\x09\x7f\x49\x39\xd9\x53\x1c\xb1\xfb\xd7\x0d\xa0\x01\x34\x1a\x0d\xe0\x5f\x3f\x00\x7c\xfd\x01\x00\xe0\x05\xc9\x5f\xbc\x86\x17\xd3\xb2\x2c\x48\x86\x24\x61\x14\xf0\x23\x91\x38\x87\x8a\xe2\xc7\x12 [...]
func wski18nResourcesEn_usAllJsonBytes() ([]byte, error) {
- return bindataRead(
- _wski18nResourcesEn_usAllJson,
- "wski18n/resources/en_US.all.json",
- )
+ return bindataRead(
+ _wski18nResourcesEn_usAllJson,
+ "wski18n/resources/en_US.all.json",
+ )
}
func wski18nResourcesEn_usAllJson() (*asset, error) {
- bytes, err := wski18nResourcesEn_usAllJsonBytes()
- if err != nil {
- return nil, err
- }
+ bytes, err := wski18nResourcesEn_usAllJsonBytes()
+ if err != nil {
+ return nil, err
+ }
- info := bindataFileInfo{name: "wski18n/resources/en_US.all.json", size: 51835, mode: os.FileMode(420), modTime: time.Unix(1510606284, 0)}
- a := &asset{bytes: bytes, info: info}
- return a, nil
+ info := bindataFileInfo{name: "wski18n/resources/en_US.all.json", size: 51835, mode: os.FileMode(420), modTime: time.Unix(1510606284, 0)}
+ a := &asset{bytes: bytes, info: info}
+ return a, nil
}
var _wski18nResourcesEs_esAllJson = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x01\x00\x00\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00")
func wski18nResourcesEs_esAllJsonBytes() ([]byte, error) {
- return bindataRead(
- _wski18nResourcesEs_esAllJson,
- "wski18n/resources/es_ES.all.json",
- )
+ return bindataRead(
+ _wski18nResourcesEs_esAllJson,
+ "wski18n/resources/es_ES.all.json",
+ )
}
func wski18nResourcesEs_esAllJson() (*asset, error) {
- bytes, err := wski18nResourcesEs_esAllJsonBytes()
- if err != nil {
- return nil, err
- }
+ bytes, err := wski18nResourcesEs_esAllJsonBytes()
+ if err != nil {
+ return nil, err
+ }
- info := bindataFileInfo{name: "wski18n/resources/es_ES.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1510606284, 0)}
- a := &asset{bytes: bytes, info: info}
- return a, nil
+ info := bindataFileInfo{name: "wski18n/resources/es_ES.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1510606284, 0)}
+ a := &asset{bytes: bytes, info: info}
+ return a, nil
}
var _wski18nResourcesFr_frAllJson = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x8a\xe6\x52\x50\xa8\xe6\x52\x50\x50\x50\x50\xca\x4c\x51\xb2\x52\x50\x4a\xaa\x2c\x48\x2c\x2e\x56\x48\x4e\x2d\x2a\xc9\x4c\xcb\x4c\x4e\x2c\x49\x55\x48\xce\x48\x4d\xce\xce\xcc\x4b\x57\xd2\x81\x28\x2c\x29\x4a\xcc\x2b\xce\x49\x2c\xc9\xcc\xcf\x03\xe9\x08\xce\xcf\x4d\x55\x40\x12\x53\xc8\xcc\x53\x70\x2b\x4a\xcd\x4b\xce\x50\xe2\x52\x50\xa8\xe5\x8a\xe5\x02\x04\x00\x00\xff\xff\x45\xa4\xe9\x62\x65\x00\x00\x00")
func wski18nResourcesFr_frAllJsonBytes() ([]byte, error) {
- return bindataRead(
- _wski18nResourcesFr_frAllJson,
- "wski18n/resources/fr_FR.all.json",
- )
+ return bindataRead(
+ _wski18nResourcesFr_frAllJson,
+ "wski18n/resources/fr_FR.all.json",
+ )
}
func wski18nResourcesFr_frAllJson() (*asset, error) {
- bytes, err := wski18nResourcesFr_frAllJsonBytes()
- if err != nil {
- return nil, err
- }
+ bytes, err := wski18nResourcesFr_frAllJsonBytes()
+ if err != nil {
+ return nil, err
+ }
- info := bindataFileInfo{name: "wski18n/resources/fr_FR.all.json", size: 101, mode: os.FileMode(420), modTime: time.Unix(1510606284, 0)}
- a := &asset{bytes: bytes, info: info}
- return a, nil
+ info := bindataFileInfo{name: "wski18n/resources/fr_FR.all.json", size: 101, mode: os.FileMode(420), modTime: time.Unix(1510606284, 0)}
+ a := &asset{bytes: bytes, info: info}
+ return a, nil
}
var _wski18nResourcesIt_itAllJson = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x01\x00\x00\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00")
func wski18nResourcesIt_itAllJsonBytes() ([]byte, error) {
- return bindataRead(
- _wski18nResourcesIt_itAllJson,
- "wski18n/resources/it_IT.all.json",
- )
+ return bindataRead(
+ _wski18nResourcesIt_itAllJson,
+ "wski18n/resources/it_IT.all.json",
+ )
}
func wski18nResourcesIt_itAllJson() (*asset, error) {
- bytes, err := wski18nResourcesIt_itAllJsonBytes()
- if err != nil {
- return nil, err
- }
+ bytes, err := wski18nResourcesIt_itAllJsonBytes()
+ if err != nil {
+ return nil, err
+ }
- info := bindataFileInfo{name: "wski18n/resources/it_IT.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1510606284, 0)}
- a := &asset{bytes: bytes, info: info}
- return a, nil
+ info := bindataFileInfo{name: "wski18n/resources/it_IT.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1510606284, 0)}
+ a := &asset{bytes: bytes, info: info}
+ return a, nil
}
var _wski18nResourcesJa_jaAllJson = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x01\x00\x00\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00")
func wski18nResourcesJa_jaAllJsonBytes() ([]byte, error) {
- return bindataRead(
- _wski18nResourcesJa_jaAllJson,
- "wski18n/resources/ja_JA.all.json",
- )
+ return bindataRead(
+ _wski18nResourcesJa_jaAllJson,
+ "wski18n/resources/ja_JA.all.json",
+ )
}
func wski18nResourcesJa_jaAllJson() (*asset, error) {
- bytes, err := wski18nResourcesJa_jaAllJsonBytes()
- if err != nil {
- return nil, err
- }
+ bytes, err := wski18nResourcesJa_jaAllJsonBytes()
+ if err != nil {
+ return nil, err
+ }
- info := bindataFileInfo{name: "wski18n/resources/ja_JA.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1510606284, 0)}
- a := &asset{bytes: bytes, info: info}
- return a, nil
+ info := bindataFileInfo{name: "wski18n/resources/ja_JA.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1510606284, 0)}
+ a := &asset{bytes: bytes, info: info}
+ return a, nil
}
var _wski18nResourcesKo_krAllJson = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x01\x00\x00\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00")
func wski18nResourcesKo_krAllJsonBytes() ([]byte, error) {
- return bindataRead(
- _wski18nResourcesKo_krAllJson,
- "wski18n/resources/ko_KR.all.json",
- )
+ return bindataRead(
+ _wski18nResourcesKo_krAllJson,
+ "wski18n/resources/ko_KR.all.json",
+ )
}
func wski18nResourcesKo_krAllJson() (*asset, error) {
- bytes, err := wski18nResourcesKo_krAllJsonBytes()
- if err != nil {
- return nil, err
- }
+ bytes, err := wski18nResourcesKo_krAllJsonBytes()
+ if err != nil {
+ return nil, err
+ }
- info := bindataFileInfo{name: "wski18n/resources/ko_KR.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1510606284, 0)}
- a := &asset{bytes: bytes, info: info}
- return a, nil
+ info := bindataFileInfo{name: "wski18n/resources/ko_KR.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1510606284, 0)}
+ a := &asset{bytes: bytes, info: info}
+ return a, nil
}
var _wski18nResourcesPt_brAllJson = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x01\x00\x00\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00")
func wski18nResourcesPt_brAllJsonBytes() ([]byte, error) {
- return bindataRead(
- _wski18nResourcesPt_brAllJson,
- "wski18n/resources/pt_BR.all.json",
- )
+ return bindataRead(
+ _wski18nResourcesPt_brAllJson,
+ "wski18n/resources/pt_BR.all.json",
+ )
}
func wski18nResourcesPt_brAllJson() (*asset, error) {
- bytes, err := wski18nResourcesPt_brAllJsonBytes()
- if err != nil {
- return nil, err
- }
+ bytes, err := wski18nResourcesPt_brAllJsonBytes()
+ if err != nil {
+ return nil, err
+ }
- info := bindataFileInfo{name: "wski18n/resources/pt_BR.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1510606284, 0)}
- a := &asset{bytes: bytes, info: info}
- return a, nil
+ info := bindataFileInfo{name: "wski18n/resources/pt_BR.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1510606284, 0)}
+ a := &asset{bytes: bytes, info: info}
+ return a, nil
}
var _wski18nResourcesZh_hansAllJson = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x01\x00\x00\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00")
func wski18nResourcesZh_hansAllJsonBytes() ([]byte, error) {
- return bindataRead(
- _wski18nResourcesZh_hansAllJson,
- "wski18n/resources/zh_Hans.all.json",
- )
+ return bindataRead(
+ _wski18nResourcesZh_hansAllJson,
+ "wski18n/resources/zh_Hans.all.json",
+ )
}
func wski18nResourcesZh_hansAllJson() (*asset, error) {
- bytes, err := wski18nResourcesZh_hansAllJsonBytes()
- if err != nil {
- return nil, err
- }
+ bytes, err := wski18nResourcesZh_hansAllJsonBytes()
+ if err != nil {
+ return nil, err
+ }
- info := bindataFileInfo{name: "wski18n/resources/zh_Hans.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1510606284, 0)}
- a := &asset{bytes: bytes, info: info}
- return a, nil
+ info := bindataFileInfo{name: "wski18n/resources/zh_Hans.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1510606284, 0)}
+ a := &asset{bytes: bytes, info: info}
+ return a, nil
}
var _wski18nResourcesZh_hantAllJson = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x01\x00\x00\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00")
func wski18nResourcesZh_hantAllJsonBytes() ([]byte, error) {
- return bindataRead(
- _wski18nResourcesZh_hantAllJson,
- "wski18n/resources/zh_Hant.all.json",
- )
+ return bindataRead(
+ _wski18nResourcesZh_hantAllJson,
+ "wski18n/resources/zh_Hant.all.json",
+ )
}
func wski18nResourcesZh_hantAllJson() (*asset, error) {
- bytes, err := wski18nResourcesZh_hantAllJsonBytes()
- if err != nil {
- return nil, err
- }
+ bytes, err := wski18nResourcesZh_hantAllJsonBytes()
+ if err != nil {
+ return nil, err
+ }
- info := bindataFileInfo{name: "wski18n/resources/zh_Hant.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1510606284, 0)}
- a := &asset{bytes: bytes, info: info}
- return a, nil
+ info := bindataFileInfo{name: "wski18n/resources/zh_Hant.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1510606284, 0)}
+ a := &asset{bytes: bytes, info: info}
+ return a, nil
}
// Asset loads and returns the asset for the given name.
// It returns an error if the asset could not be found or
// could not be loaded.
func Asset(name string) ([]byte, error) {
- cannonicalName := strings.Replace(name, "\\", "/", -1)
- if f, ok := _bindata[cannonicalName]; ok {
- a, err := f()
- if err != nil {
- return nil, fmt.Errorf("Asset %s can't read by error: %v", name, err)
- }
- return a.bytes, nil
- }
- return nil, fmt.Errorf("Asset %s not found", name)
+ cannonicalName := strings.Replace(name, "\\", "/", -1)
+ if f, ok := _bindata[cannonicalName]; ok {
+ a, err := f()
+ if err != nil {
+ return nil, fmt.Errorf("Asset %s can't read by error: %v", name, err)
+ }
+ return a.bytes, nil
+ }
+ return nil, fmt.Errorf("Asset %s not found", name)
}
// MustAsset is like Asset but panics when Asset would return an error.
// It simplifies safe initialization of global variables.
func MustAsset(name string) []byte {
- a, err := Asset(name)
- if err != nil {
- panic("asset: Asset(" + name + "): " + err.Error())
- }
+ a, err := Asset(name)
+ if err != nil {
+ panic("asset: Asset(" + name + "): " + err.Error())
+ }
- return a
+ return a
}
// AssetInfo loads and returns the asset info for the given name.
// It returns an error if the asset could not be found or
// could not be loaded.
func AssetInfo(name string) (os.FileInfo, error) {
- cannonicalName := strings.Replace(name, "\\", "/", -1)
- if f, ok := _bindata[cannonicalName]; ok {
- a, err := f()
- if err != nil {
- return nil, fmt.Errorf("AssetInfo %s can't read by error: %v", name, err)
- }
- return a.info, nil
- }
- return nil, fmt.Errorf("AssetInfo %s not found", name)
+ cannonicalName := strings.Replace(name, "\\", "/", -1)
+ if f, ok := _bindata[cannonicalName]; ok {
+ a, err := f()
+ if err != nil {
+ return nil, fmt.Errorf("AssetInfo %s can't read by error: %v", name, err)
+ }
+ return a.info, nil
+ }
+ return nil, fmt.Errorf("AssetInfo %s not found", name)
}
// AssetNames returns the names of the assets.
func AssetNames() []string {
- names := make([]string, 0, len(_bindata))
- for name := range _bindata {
- names = append(names, name)
- }
- return names
+ names := make([]string, 0, len(_bindata))
+ for name := range _bindata {
+ names = append(names, name)
+ }
+ return names
}
// _bindata is a table, holding each asset generator, mapped to its name.
var _bindata = map[string]func() (*asset, error){
- "wski18n/resources/de_DE.all.json": wski18nResourcesDe_deAllJson,
- "wski18n/resources/en_US.all.json": wski18nResourcesEn_usAllJson,
- "wski18n/resources/es_ES.all.json": wski18nResourcesEs_esAllJson,
- "wski18n/resources/fr_FR.all.json": wski18nResourcesFr_frAllJson,
- "wski18n/resources/it_IT.all.json": wski18nResourcesIt_itAllJson,
- "wski18n/resources/ja_JA.all.json": wski18nResourcesJa_jaAllJson,
- "wski18n/resources/ko_KR.all.json": wski18nResourcesKo_krAllJson,
- "wski18n/resources/pt_BR.all.json": wski18nResourcesPt_brAllJson,
- "wski18n/resources/zh_Hans.all.json": wski18nResourcesZh_hansAllJson,
- "wski18n/resources/zh_Hant.all.json": wski18nResourcesZh_hantAllJson,
+ "wski18n/resources/de_DE.all.json": wski18nResourcesDe_deAllJson,
+ "wski18n/resources/en_US.all.json": wski18nResourcesEn_usAllJson,
+ "wski18n/resources/es_ES.all.json": wski18nResourcesEs_esAllJson,
+ "wski18n/resources/fr_FR.all.json": wski18nResourcesFr_frAllJson,
+ "wski18n/resources/it_IT.all.json": wski18nResourcesIt_itAllJson,
+ "wski18n/resources/ja_JA.all.json": wski18nResourcesJa_jaAllJson,
+ "wski18n/resources/ko_KR.all.json": wski18nResourcesKo_krAllJson,
+ "wski18n/resources/pt_BR.all.json": wski18nResourcesPt_brAllJson,
+ "wski18n/resources/zh_Hans.all.json": wski18nResourcesZh_hansAllJson,
+ "wski18n/resources/zh_Hant.all.json": wski18nResourcesZh_hantAllJson,
}
// AssetDir returns the file names below a certain
@@ -372,92 +372,92 @@ var _bindata = map[string]func() (*asset, error){
// AssetDir("foo.txt") and AssetDir("notexist") would return an error
// AssetDir("") will return []string{"data"}.
func AssetDir(name string) ([]string, error) {
- node := _bintree
- if len(name) != 0 {
- cannonicalName := strings.Replace(name, "\\", "/", -1)
- pathList := strings.Split(cannonicalName, "/")
- for _, p := range pathList {
- node = node.Children[p]
- if node == nil {
- return nil, fmt.Errorf("Asset %s not found", name)
- }
- }
- }
- if node.Func != nil {
- return nil, fmt.Errorf("Asset %s not found", name)
- }
- rv := make([]string, 0, len(node.Children))
- for childName := range node.Children {
- rv = append(rv, childName)
- }
- return rv, nil
+ node := _bintree
+ if len(name) != 0 {
+ cannonicalName := strings.Replace(name, "\\", "/", -1)
+ pathList := strings.Split(cannonicalName, "/")
+ for _, p := range pathList {
+ node = node.Children[p]
+ if node == nil {
+ return nil, fmt.Errorf("Asset %s not found", name)
+ }
+ }
+ }
+ if node.Func != nil {
+ return nil, fmt.Errorf("Asset %s not found", name)
+ }
+ rv := make([]string, 0, len(node.Children))
+ for childName := range node.Children {
+ rv = append(rv, childName)
+ }
+ return rv, nil
}
type bintree struct {
- Func func() (*asset, error)
- Children map[string]*bintree
+ Func func() (*asset, error)
+ Children map[string]*bintree
}
+
var _bintree = &bintree{nil, map[string]*bintree{
- "wski18n": &bintree{nil, map[string]*bintree{
- "resources": &bintree{nil, map[string]*bintree{
- "de_DE.all.json": &bintree{wski18nResourcesDe_deAllJson, map[string]*bintree{}},
- "en_US.all.json": &bintree{wski18nResourcesEn_usAllJson, map[string]*bintree{}},
- "es_ES.all.json": &bintree{wski18nResourcesEs_esAllJson, map[string]*bintree{}},
- "fr_FR.all.json": &bintree{wski18nResourcesFr_frAllJson, map[string]*bintree{}},
- "it_IT.all.json": &bintree{wski18nResourcesIt_itAllJson, map[string]*bintree{}},
- "ja_JA.all.json": &bintree{wski18nResourcesJa_jaAllJson, map[string]*bintree{}},
- "ko_KR.all.json": &bintree{wski18nResourcesKo_krAllJson, map[string]*bintree{}},
- "pt_BR.all.json": &bintree{wski18nResourcesPt_brAllJson, map[string]*bintree{}},
- "zh_Hans.all.json": &bintree{wski18nResourcesZh_hansAllJson, map[string]*bintree{}},
- "zh_Hant.all.json": &bintree{wski18nResourcesZh_hantAllJson, map[string]*bintree{}},
- }},
- }},
+ "wski18n": {nil, map[string]*bintree{
+ "resources": {nil, map[string]*bintree{
+ "de_DE.all.json": {wski18nResourcesDe_deAllJson, map[string]*bintree{}},
+ "en_US.all.json": {wski18nResourcesEn_usAllJson, map[string]*bintree{}},
+ "es_ES.all.json": {wski18nResourcesEs_esAllJson, map[string]*bintree{}},
+ "fr_FR.all.json": {wski18nResourcesFr_frAllJson, map[string]*bintree{}},
+ "it_IT.all.json": {wski18nResourcesIt_itAllJson, map[string]*bintree{}},
+ "ja_JA.all.json": {wski18nResourcesJa_jaAllJson, map[string]*bintree{}},
+ "ko_KR.all.json": {wski18nResourcesKo_krAllJson, map[string]*bintree{}},
+ "pt_BR.all.json": {wski18nResourcesPt_brAllJson, map[string]*bintree{}},
+ "zh_Hans.all.json": {wski18nResourcesZh_hansAllJson, map[string]*bintree{}},
+ "zh_Hant.all.json": {wski18nResourcesZh_hantAllJson, map[string]*bintree{}},
+ }},
+ }},
}}
// RestoreAsset restores an asset under the given directory
func RestoreAsset(dir, name string) error {
- data, err := Asset(name)
- if err != nil {
- return err
- }
- info, err := AssetInfo(name)
- if err != nil {
- return err
- }
- err = os.MkdirAll(_filePath(dir, filepath.Dir(name)), os.FileMode(0755))
- if err != nil {
- return err
- }
- err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode())
- if err != nil {
- return err
- }
- err = os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime())
- if err != nil {
- return err
- }
- return nil
+ data, err := Asset(name)
+ if err != nil {
+ return err
+ }
+ info, err := AssetInfo(name)
+ if err != nil {
+ return err
+ }
+ err = os.MkdirAll(_filePath(dir, filepath.Dir(name)), os.FileMode(0755))
+ if err != nil {
+ return err
+ }
+ err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode())
+ if err != nil {
+ return err
+ }
+ err = os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime())
+ if err != nil {
+ return err
+ }
+ return nil
}
// RestoreAssets restores an asset under the given directory recursively
func RestoreAssets(dir, name string) error {
- children, err := AssetDir(name)
- // File
- if err != nil {
- return RestoreAsset(dir, name)
- }
- // Dir
- for _, child := range children {
- err = RestoreAssets(dir, filepath.Join(name, child))
- if err != nil {
- return err
- }
- }
- return nil
+ children, err := AssetDir(name)
+ // File
+ if err != nil {
+ return RestoreAsset(dir, name)
+ }
+ // Dir
+ for _, child := range children {
+ err = RestoreAssets(dir, filepath.Join(name, child))
+ if err != nil {
+ return err
+ }
+ }
+ return nil
}
func _filePath(dir, name string) string {
- cannonicalName := strings.Replace(name, "\\", "/", -1)
- return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...)
+ cannonicalName := strings.Replace(name, "\\", "/", -1)
+ return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...)
}
-
--
To stop receiving notification emails like this one, please contact
csantanapr@apache.org.