You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by ho...@apache.org on 2017/06/01 19:50:48 UTC
[incubator-openwhisk-cli] branch master updated: Add scancode to
travis and fix all scancode errors (#46)
This is an automated email from the ASF dual-hosted git repository.
houshengbo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-cli.git
The following commit(s) were added to refs/heads/master by this push:
new e06380d Add scancode to travis and fix all scancode errors (#46)
e06380d is described below
commit e06380de5817b36f183e2fa55b6ccff45bf4eda7
Author: Matt Rutkowski <mr...@us.ibm.com>
AuthorDate: Thu Jun 1 14:50:45 2017 -0500
Add scancode to travis and fix all scancode errors (#46)
* Add scanCode to Travis and fix all scanCode errors.
* Add scanCode to Travis and fix all scanCode errors.
* Add scanCode to Travis and fix all scanCode errors.
* Add scanCode to Travis and fix all scanCode errors.
* Add scanCode to Travis and fix all scanCode errors.
* Add scanCode to Travis and fix all scanCode errors.
* Add scanCode to Travis and fix all scanCode errors.
* Add scanCode to Travis and fix all scanCode errors.
* Add scanCode to Travis and fix all scanCode errors.
* Add scanCode to Travis and fix all scanCode errors.
* Update i18n_resource.go with most current timestamps.
---
.travis.yml | 5 +
notes.md | 136 ++--
tests/src/dat/hello.js | 2 +-
tests/src/integration/command_test.go | 957 +++++++++++++-------------
tests/src/integration/common/utils.go | 134 ++--
tests/src/integration/common/wsk.go | 70 +-
tests/src/integration/common/wskprops.go | 68 +-
tests/src/integration/integration_test.go | 1053 +++++++++++++++--------------
tools/travis/scancode.sh | 11 +
tools/travis/setupscan.sh | 8 +
wski18n/i18n_resources.go | 1 -
11 files changed, 1275 insertions(+), 1170 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 1765c49..5f5140a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -16,13 +16,18 @@ matrix:
git:
depth: 3
+before_install:
+ - pip install --upgrade pip setuptools
+
install:
+ - ./tools/travis/setupscan.sh
- export DEPLOY_BUILD_READY=false
- go get -u github.com/golang/lint/golint
- go get -u github.com/stretchr/testify
- go get -u github.com/spf13/viper
script:
+ - ./tools/travis/scancode.sh
- make lint
- make build
- make test
diff --git a/notes.md b/notes.md
index 0c5cca6..137968f 100644
--- a/notes.md
+++ b/notes.md
@@ -570,39 +570,39 @@ from `commands/hugo.go`
// Execute adds all child commands to the root command HugoCmd and sets flags appropriately.
func Execute() {
- HugoCmd.SetGlobalNormalizationFunc(helpers.NormalizeHugoFlags)
+ HugoCmd.SetGlobalNormalizationFunc(helpers.NormalizeHugoFlags)
- HugoCmd.SilenceUsage = true
+ HugoCmd.SilenceUsage = true
- AddCommands()
+ AddCommands()
- if c, err := HugoCmd.ExecuteC(); err != nil {
- if isUserError(err) {
- c.Println("")
- c.Println(c.UsageString())
- }
+ if c, err := HugoCmd.ExecuteC(); err != nil {
+ if isUserError(err) {
+ c.Println("")
+ c.Println(c.UsageString())
+ }
- return
- }
+ return
+ }
}
// AddCommands adds child commands to the root command HugoCmd.
func AddCommands() {
- HugoCmd.AddCommand(serverCmd)
- HugoCmd.AddCommand(versionCmd)
- HugoCmd.AddCommand(configCmd)
- HugoCmd.AddCommand(checkCmd)
- HugoCmd.AddCommand(benchmarkCmd)
- HugoCmd.AddCommand(convertCmd)
- HugoCmd.AddCommand(newCmd)
- HugoCmd.AddCommand(listCmd)
- HugoCmd.AddCommand(undraftCmd)
- HugoCmd.AddCommand(importCmd)
-
- HugoCmd.AddCommand(genCmd)
- genCmd.AddCommand(genautocompleteCmd)
- genCmd.AddCommand(gendocCmd)
- genCmd.AddCommand(genmanCmd)
+ HugoCmd.AddCommand(serverCmd)
+ HugoCmd.AddCommand(versionCmd)
+ HugoCmd.AddCommand(configCmd)
+ HugoCmd.AddCommand(checkCmd)
+ HugoCmd.AddCommand(benchmarkCmd)
+ HugoCmd.AddCommand(convertCmd)
+ HugoCmd.AddCommand(newCmd)
+ HugoCmd.AddCommand(listCmd)
+ HugoCmd.AddCommand(undraftCmd)
+ HugoCmd.AddCommand(importCmd)
+
+ HugoCmd.AddCommand(genCmd)
+ genCmd.AddCommand(genautocompleteCmd)
+ genCmd.AddCommand(gendocCmd)
+ genCmd.AddCommand(genmanCmd)
}
```
@@ -620,32 +620,32 @@ var BuildWatch, IgnoreCache, Draft, Future, UglyURLs, CanonifyURLs, Verbose, Log
var Source, CacheDir, Destination, Theme, BaseURL, CfgFile, LogFile, Editor string
func initCoreCommonFlags(cmd *cobra.Command) {
- cmd.Flags().BoolVarP(&Draft, "buildDrafts", "D", false, "include content marked as draft")
- cmd.Flags().BoolVarP(&Future, "buildFuture", "F", false, "include content with publishdate in the future")
- cmd.Flags().BoolVar(&DisableRSS, "disableRSS", false, "Do not build RSS files")
- cmd.Flags().BoolVar(&DisableSitemap, "disableSitemap", false, "Do not build Sitemap file")
- cmd.Flags().BoolVar(&DisableRobotsTXT, "disableRobotsTXT", false, "Do not build Robots TXT file")
- cmd.Flags().StringVarP(&Source, "source", "s", "", "filesystem path to read files relative from")
- cmd.Flags().StringVarP(&CacheDir, "cacheDir", "", "", "filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache/")
- cmd.Flags().BoolVarP(&IgnoreCache, "ignoreCache", "", false, "Ignores the cache directory for reading but still writes to it")
- cmd.Flags().StringVarP(&Destination, "destination", "d", "", "filesystem path to write files to")
- cmd.Flags().StringVarP(&Theme, "theme", "t", "", "theme to use (located in /themes/THEMENAME/)")
- cmd.Flags().BoolVar(&UglyURLs, "uglyURLs", false, "if true, use /filename.html instead of /filename/")
- cmd.Flags().BoolVar(&CanonifyURLs, "canonifyURLs", false, "if true, all relative URLs will be canonicalized using baseURL")
- cmd.Flags().StringVarP(&BaseURL, "baseURL", "b", "", "hostname (and path) to the root, e.g. http://spf13.com/")
- cmd.Flags().StringVar(&CfgFile, "config", "", "config file (default is path/config.yaml|json|toml)")
- cmd.Flags().StringVar(&Editor, "editor", "", "edit new content with this editor, if provided")
- cmd.Flags().BoolVar(&nitro.AnalysisOn, "stepAnalysis", false, "display memory and timing of different steps of the program")
- cmd.Flags().BoolVar(&PluralizeListTitles, "pluralizeListTitles", true, "Pluralize titles in lists using inflect")
- cmd.Flags().BoolVar(&PreserveTaxonomyNames, "preserveTaxonomyNames", false, `Preserve taxonomy names as written ("Gérard Depardieu" vs "gerard-depardieu")`)
- cmd.Flags().BoolVarP(&ForceSync, "forceSyncStatic", "", false, "Copy all files when static is changed.")
- // For bash-completion
- validConfigFilenames := []string{"json", "js", "yaml", "yml", "toml", "tml"}
- cmd.Flags().SetAnnotation("config", cobra.BashCompFilenameExt, validConfigFilenames)
- cmd.Flags().SetAnnotation("source", cobra.BashCompSubdirsInDir, []string{})
- cmd.Flags().SetAnnotation("cacheDir", cobra.BashCompSubdirsInDir, []string{})
- cmd.Flags().SetAnnotation("destination", cobra.BashCompSubdirsInDir, []string{})
- cmd.Flags().SetAnnotation("theme", cobra.BashCompSubdirsInDir, []string{"themes"})
+ cmd.Flags().BoolVarP(&Draft, "buildDrafts", "D", false, "include content marked as draft")
+ cmd.Flags().BoolVarP(&Future, "buildFuture", "F", false, "include content with publishdate in the future")
+ cmd.Flags().BoolVar(&DisableRSS, "disableRSS", false, "Do not build RSS files")
+ cmd.Flags().BoolVar(&DisableSitemap, "disableSitemap", false, "Do not build Sitemap file")
+ cmd.Flags().BoolVar(&DisableRobotsTXT, "disableRobotsTXT", false, "Do not build Robots TXT file")
+ cmd.Flags().StringVarP(&Source, "source", "s", "", "filesystem path to read files relative from")
+ cmd.Flags().StringVarP(&CacheDir, "cacheDir", "", "", "filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache/")
+ cmd.Flags().BoolVarP(&IgnoreCache, "ignoreCache", "", false, "Ignores the cache directory for reading but still writes to it")
+ cmd.Flags().StringVarP(&Destination, "destination", "d", "", "filesystem path to write files to")
+ cmd.Flags().StringVarP(&Theme, "theme", "t", "", "theme to use (located in /themes/THEMENAME/)")
+ cmd.Flags().BoolVar(&UglyURLs, "uglyURLs", false, "if true, use /filename.html instead of /filename/")
+ cmd.Flags().BoolVar(&CanonifyURLs, "canonifyURLs", false, "if true, all relative URLs will be canonicalized using baseURL")
+ cmd.Flags().StringVarP(&BaseURL, "baseURL", "b", "", "hostname (and path) to the root, e.g. http://spf13.com/")
+ cmd.Flags().StringVar(&CfgFile, "config", "", "config file (default is path/config.yaml|json|toml)")
+ cmd.Flags().StringVar(&Editor, "editor", "", "edit new content with this editor, if provided")
+ cmd.Flags().BoolVar(&nitro.AnalysisOn, "stepAnalysis", false, "display memory and timing of different steps of the program")
+ cmd.Flags().BoolVar(&PluralizeListTitles, "pluralizeListTitles", true, "Pluralize titles in lists using inflect")
+ cmd.Flags().BoolVar(&PreserveTaxonomyNames, "preserveTaxonomyNames", false, `Preserve taxonomy names as written ("Gérard Depardieu" vs "gerard-depardieu")`)
+ cmd.Flags().BoolVarP(&ForceSync, "forceSyncStatic", "", false, "Copy all files when static is changed.")
+ // For bash-completion
+ validConfigFilenames := []string{"json", "js", "yaml", "yml", "toml", "tml"}
+ cmd.Flags().SetAnnotation("config", cobra.BashCompFilenameExt, validConfigFilenames)
+ cmd.Flags().SetAnnotation("source", cobra.BashCompSubdirsInDir, []string{})
+ cmd.Flags().SetAnnotation("cacheDir", cobra.BashCompSubdirsInDir, []string{})
+ cmd.Flags().SetAnnotation("destination", cobra.BashCompSubdirsInDir, []string{})
+ cmd.Flags().SetAnnotation("theme", cobra.BashCompSubdirsInDir, []string{"themes"})
}
```
@@ -705,23 +705,23 @@ possible solution: use pointers. if pointer is nil, then ignore.
```go
func addRouteOptions(route string, options interface{}) (string, error) {
- v := reflect.ValueOf(options)
- if v.Kind() == reflect.Ptr && v.IsNil() {
- return route, nil
- }
-
- u, err := url.Parse(route)
- if err != nil {
- return route, err
- }
-
- qs, err := query.Values(options)
- if err != nil {
- return route, err
- }
-
- u.RawQuery = qs.Encode()
- return u.String(), nil
+ v := reflect.ValueOf(options)
+ if v.Kind() == reflect.Ptr && v.IsNil() {
+ return route, nil
+ }
+
+ u, err := url.Parse(route)
+ if err != nil {
+ return route, err
+ }
+
+ qs, err := query.Values(options)
+ if err != nil {
+ return route, err
+ }
+
+ u.RawQuery = qs.Encode()
+ return u.String(), nil
}
```
- How does go-querystring/query.Values() work ?? has options ??
diff --git a/tests/src/dat/hello.js b/tests/src/dat/hello.js
index c40254d..82b3bcf 100644
--- a/tests/src/dat/hello.js
+++ b/tests/src/dat/hello.js
@@ -5,4 +5,4 @@ function main(params) {
greeting = 'hello, ' + params.payload + '!'
console.log(greeting);
return {payload: greeting}
-}
\ No newline at end of file
+}
diff --git a/tests/src/integration/command_test.go b/tests/src/integration/command_test.go
index 4949e70..bc08df1 100644
--- a/tests/src/integration/command_test.go
+++ b/tests/src/integration/command_test.go
@@ -1,12 +1,29 @@
// +build native
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package tests
import (
- "testing"
- "os"
- "github.com/stretchr/testify/assert"
- "github.com/apache/incubator-openwhisk-cli/tests/src/integration/common"
+ "testing"
+ "os"
+ "github.com/stretchr/testify/assert"
+ "github.com/apache/incubator-openwhisk-cli/tests/src/integration/common"
)
var wsk *common.Wsk = common.NewWsk()
@@ -25,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{
+ 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,
+ },
+ }
}
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,
- },
- }
+ 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,
+ },
+ }
}
// 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 0f51b6d..4f9064d 100644
--- a/tests/src/integration/common/utils.go
+++ b/tests/src/integration/common/utils.go
@@ -1,87 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package common
import (
- "fmt"
- "os"
- "unicode"
- "io"
- "strings"
+ "fmt"
+ "os"
+ "unicode"
+ "io"
+ "strings"
)
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 {
@@ -89,6 +105,6 @@ func GetRepoPath() string {
}
type InvalidArg struct {
- Cmd []string
- Err string
-}
\ No newline at end of file
+ Cmd []string
+ Err string
+}
diff --git a/tests/src/integration/common/wsk.go b/tests/src/integration/common/wsk.go
index ec9b9cc..aa7d87f 100644
--- a/tests/src/integration/common/wsk.go
+++ b/tests/src/integration/common/wsk.go
@@ -1,51 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package common
import (
- "os"
- "os/exec"
+ "os"
+ "os/exec"
)
const cmd = "wsk"
const arg = "-i"
type Wsk struct {
- Path string
- Arg []string
- Dir string
- Wskprops *Wskprops
+ Path string
+ Arg []string
+ Dir string
+ Wskprops *Wskprops
}
func NewWsk() *Wsk {
- return NewWskWithPath(GetRepoPath())
+ return NewWskWithPath(GetRepoPath())
}
func NewWskWithPath(path string) *Wsk {
- var dep Wsk
- dep.Path = cmd
- dep.Arg = []string{arg}
- dep.Dir = path
- dep.Wskprops = GetWskprops()
- return &dep
+ var dep Wsk
+ dep.Path = cmd
+ dep.Arg = []string{arg}
+ dep.Dir = path
+ dep.Wskprops = GetWskprops()
+ return &dep
}
func (wsk *Wsk)Exists() bool {
- _, err := os.Stat(wsk.Dir + "/" + wsk.Path);
- if err == nil {
- return true
- } else {
- return false
- }
+ _, 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.Path, cs...)
- command.Dir = wsk.Dir
- return command.CombinedOutput()
+ cs := wsk.Arg
+ cs = append(cs, s...)
+ command := exec.Command(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)
-}
\ No newline at end of file
+ return wsk.RunCommand("namespace", "list", "--apihost", wsk.Wskprops.APIHost,
+ "--auth", wsk.Wskprops.AuthKey)
+}
diff --git a/tests/src/integration/common/wskprops.go b/tests/src/integration/common/wskprops.go
index ae493c1..876a5de 100644
--- a/tests/src/integration/common/wskprops.go
+++ b/tests/src/integration/common/wskprops.go
@@ -1,39 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package common
import (
- "github.com/spf13/viper"
- "io/ioutil"
- "os"
+ "github.com/spf13/viper"
+ "io/ioutil"
+ "os"
)
type Wskprops struct {
- APIHost string
- APIVersion string
- AuthKey string
- ControllerHost string
- ControllerPort string
+ APIHost string
+ APIVersion string
+ AuthKey string
+ ControllerHost string
+ ControllerPort string
}
func GetWskprops() *Wskprops {
- var dep Wskprops
- dep.APIHost = ""
- dep.AuthKey = ""
- dep.APIVersion = "v1"
+ var dep Wskprops
+ dep.APIHost = ""
+ dep.AuthKey = ""
+ dep.APIVersion = "v1"
- viper.SetConfigName("whisk")
- viper.AddConfigPath(os.Getenv("OPENWHISK_HOME"))
+ viper.SetConfigName("whisk")
+ viper.AddConfigPath(os.Getenv("OPENWHISK_HOME"))
- err := viper.ReadInConfig()
- if err == nil {
- authPath := viper.GetString("testing.auth")
+ err := viper.ReadInConfig()
+ if err == nil {
+ authPath := viper.GetString("testing.auth")
- b, err := ioutil.ReadFile(authPath)
- if err == nil {
- dep.AuthKey = string(b)
- }
- dep.APIHost = viper.GetString("router.host")
- dep.ControllerHost = viper.GetString("router.host")
- dep.ControllerPort = viper.GetString("controller.host.port")
- }
- return &dep
+ b, err := ioutil.ReadFile(authPath)
+ if err == nil {
+ dep.AuthKey = string(b)
+ }
+ dep.APIHost = viper.GetString("router.host")
+ dep.ControllerHost = viper.GetString("router.host")
+ dep.ControllerPort = viper.GetString("controller.host.port")
+ }
+ return &dep
}
diff --git a/tests/src/integration/integration_test.go b/tests/src/integration/integration_test.go
index 9dfd9b7..3224e09 100644
--- a/tests/src/integration/integration_test.go
+++ b/tests/src/integration/integration_test.go
@@ -1,13 +1,30 @@
// +build integration
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package tests
import (
- "testing"
- "github.com/stretchr/testify/assert"
- "github.com/apache/incubator-openwhisk-cli/tests/src/integration/common"
- "os"
- "strings"
+ "testing"
+ "github.com/stretchr/testify/assert"
+ "github.com/apache/incubator-openwhisk-cli/tests/src/integration/common"
+ "os"
+ "strings"
)
var invalidArgs []common.InvalidArg
@@ -34,308 +51,308 @@ 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{"api-experimental", "create"},
- Err: tooFewArgsMsg + " " + apiCreateReqMsg,
- },
- common.InvalidArg {
- Cmd: []string{"api-experimental", "create", "/basepath", "/path", "GET", "action", invalidArg},
- Err: tooManyArgsMsg + invalidArg + ". " + apiCreateReqMsg,
- },
- common.InvalidArg {
- Cmd: []string{"api-experimental", "get"},
- Err: tooFewArgsMsg + " " + apiGetReqMsg,
- },
- common.InvalidArg {
- Cmd: []string{"api-experimental", "get", "/basepath", invalidArg},
- Err: tooManyArgsMsg + invalidArg + ". " + apiGetReqMsg,
- },
- common.InvalidArg {
- Cmd: []string{"api-experimental", "delete"},
- Err: tooFewArgsMsg + " " + apiDeleteReqMsg,
- },
- common.InvalidArg {
- Cmd: []string{"api-experimental", "delete", "/basepath", "/path", "GET", invalidArg},
- Err: tooManyArgsMsg + invalidArg + ". " + apiDeleteReqMsg,
- },
- common.InvalidArg {
- Cmd: []string{"api-experimental", "list", "/basepath", "/path", "GET", invalidArg},
- Err: tooManyArgsMsg + invalidArg + ". " + apiListReqMsg,
- },
- 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{
+ common.InvalidArg {
+ Cmd: []string{"api-experimental", "create"},
+ Err: tooFewArgsMsg + " " + apiCreateReqMsg,
+ },
+ common.InvalidArg {
+ Cmd: []string{"api-experimental", "create", "/basepath", "/path", "GET", "action", invalidArg},
+ Err: tooManyArgsMsg + invalidArg + ". " + apiCreateReqMsg,
+ },
+ common.InvalidArg {
+ Cmd: []string{"api-experimental", "get"},
+ Err: tooFewArgsMsg + " " + apiGetReqMsg,
+ },
+ common.InvalidArg {
+ Cmd: []string{"api-experimental", "get", "/basepath", invalidArg},
+ Err: tooManyArgsMsg + invalidArg + ". " + apiGetReqMsg,
+ },
+ common.InvalidArg {
+ Cmd: []string{"api-experimental", "delete"},
+ Err: tooFewArgsMsg + " " + apiDeleteReqMsg,
+ },
+ common.InvalidArg {
+ Cmd: []string{"api-experimental", "delete", "/basepath", "/path", "GET", invalidArg},
+ Err: tooManyArgsMsg + invalidArg + ". " + apiDeleteReqMsg,
+ },
+ common.InvalidArg {
+ Cmd: []string{"api-experimental", "list", "/basepath", "/path", "GET", invalidArg},
+ Err: tooManyArgsMsg + invalidArg + ". " + apiListReqMsg,
+ },
+ 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 + ".",
+ },
- 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", "namespace", invalidArg},
- Err: tooManyArgsMsg + invalidArg + ". " + optNamespaceMsg,
- },
- 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 + ".",
- },
+ 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", "namespace", invalidArg},
+ Err: tooManyArgsMsg + invalidArg + ". " + optNamespaceMsg,
+ },
+ 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 + ".",
+ },
- 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,
- },
+ 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,
+ },
- 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 + ".",
- },
+ 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 + ".",
+ },
- 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,
- },
- }
+ 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,
+ },
+ }
}
var wsk *common.Wsk = common.NewWsk()
@@ -343,255 +360,255 @@ 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])
- 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])
+ 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.")
- 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.")
+ 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 := "http://" + wsk.Wskprops.ControllerHost + ":" + wsk.Wskprops.ControllerPort
- 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")
- 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 := "http://" + wsk.Wskprops.ControllerHost + ":" + wsk.Wskprops.ControllerPort
+ 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")
+ 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.")
- 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\".")
- }
+ 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.")
+ 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 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{
+ 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,
+ },
+ }
- 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{
+ 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,
+ },
+ }
- 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 + " .")
- }
- }
-}
\ No newline at end of file
+ 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/tools/travis/scancode.sh b/tools/travis/scancode.sh
new file mode 100755
index 0000000..2202c45
--- /dev/null
+++ b/tools/travis/scancode.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+set -e
+
+# Build script for Travis-CI.
+SCRIPTDIR=$(cd $(dirname "$0") && pwd)
+ROOTDIR="$SCRIPTDIR/../.."
+UTIL_DIR="$ROOTDIR/../incubator-openwhisk-utilities"
+
+# run scancode
+cd $UTIL_DIR
+scancode/scanCode.py $ROOTDIR
\ No newline at end of file
diff --git a/tools/travis/setupscan.sh b/tools/travis/setupscan.sh
new file mode 100755
index 0000000..35f070f
--- /dev/null
+++ b/tools/travis/setupscan.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+SCRIPTDIR=$(cd $(dirname "$0") && pwd)
+HOMEDIR="$SCRIPTDIR/../../../"
+
+# clone OpenWhisk utilities repo. in order to run scanCode.py
+cd $HOMEDIR
+git clone https://github.com/apache/incubator-openwhisk-utilities.git
diff --git a/wski18n/i18n_resources.go b/wski18n/i18n_resources.go
index 4ca1607..0bd3e7d 100644
--- a/wski18n/i18n_resources.go
+++ b/wski18n/i18n_resources.go
@@ -460,4 +460,3 @@ func _filePath(dir, name string) string {
cannonicalName := strings.Replace(name, "\\", "/", -1)
return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...)
}
-
--
To stop receiving notification emails like this one, please contact
['"commits@openwhisk.apache.org" <co...@openwhisk.apache.org>'].