Skip to content

Commit

Permalink
Added test cases for quoted strings.
Browse files Browse the repository at this point in the history
  • Loading branch information
jessealva committed Nov 30, 2017
1 parent 515d0dd commit e8cfa2e
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/src/test/scala/system/basic/WskConsoleTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,14 @@ abstract class WskConsoleTests extends TestHelpers with WskTestHelpers {
}
}

it should "invoke an action and poll activations and verify that action names are quoted." in withAssetCleaner(wskprops) {
(wp, assetHelper) =>
val name = "helloRunActivationPoll"
assetHelper.withCleaner(wsk.action, name) { (action, _) =>
action.create(name, Some(TestCLIUtils.getTestActionFilename("hello.js")))
}
val activationId = wsk.action.invoke(name)
val pollResults = wsk.activation.console(duration = 5.second, actionName = Some(name))
pollResults.stdout should include (s"""Activation: '${name}'""")
}
}
72 changes: 72 additions & 0 deletions tests/src/test/scala/system/basic/WskSdkTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import common.Wsk
import common.WskProps
import common.WskTestHelpers

import scala.sys.process._

@RunWith(classOf[JUnitRunner])
class WskSdkTests extends TestHelpers with WskTestHelpers {

Expand Down Expand Up @@ -82,6 +84,76 @@ class WskSdkTests extends TestHelpers with WskTestHelpers {
}
}

it should "download docker sdk when blackbox.tar.gz exists, and docker name should be quoted in error." in {
val fileName = "blackbox.tar.gz"
val dir = File.createTempFile("wskinstall", ".tmp")
dir.delete()
dir.mkdir() should be(true)
val file = new File(dir, fileName)
file.createNewFile should be (true)
try {
wsk.cli(wskprops.overrides ++ Seq("sdk", "install", "docker"),
workingDir = dir,
expectedExitCode = 1).stderr should include(
s"""The file '${fileName}' already exists. Delete it and retry.""")
} finally {
file.delete()
FileUtils.deleteDirectory(dir)
}
}

it should "download ios sdk when OpenWhiskIOSStarterApp.zip exists, and ios name should be quoted in error." in {
val fileName = "OpenWhiskIOSStarterApp.zip"
val dir = File.createTempFile("wskinstall", ".tmp")
dir.delete()
dir.mkdir() should be(true)
val file = new File(dir, fileName)
file.createNewFile should be (true)
try {
wsk.cli(wskprops.overrides ++ Seq("sdk", "install", "ios"),
workingDir = dir,
expectedExitCode = 1).stderr should include(
s"""The file '${fileName}' already exists. Delete it and retry.""")
} finally {
file.delete()
FileUtils.deleteDirectory(dir)
}
}

it should "download ios sdk, check filename is quoted in error when create fails." in {
val fileName = "OpenWhiskIOSStarterApp.zip"
val dir = File.createTempFile("wskinstall", ".tmp")
dir.delete()
dir.mkdir() should be(true)
Seq("chmod", "555", dir.getAbsolutePath).!!
try {
wsk.cli(wskprops.overrides ++ Seq("sdk", "install", "ios"),
workingDir = dir,
expectedExitCode = 1).stderr should include(
s"""Error creating SDK file '${fileName}':""")
} finally {
FileUtils.deleteDirectory(dir)
}
}

it should "download docker sdk twice, check directory is quoted in error when create fails." in {
val dir = File.createTempFile("wskinstall", ".tmp")
dir.delete()
dir.mkdir() should be(true)
try {
wsk.cli(wskprops.overrides ++ Seq("sdk", "install", "docker"),
workingDir = dir).stdout should include(
s"""The docker skeleton is now installed at the current directory.""")

wsk.cli(wskprops.overrides ++ Seq("sdk", "install", "docker"),
workingDir = dir,
expectedExitCode = 1).stderr should include(
s"""The directory 'dockerSkeleton' already exists. Delete it and retry.""")
} finally {
FileUtils.deleteDirectory(dir)
}
}

it should "download iOS sdk" in {
val dir = File.createTempFile("wskinstall", ".tmp")
dir.delete()
Expand Down
26 changes: 26 additions & 0 deletions tests/src/test/scala/whisk/core/cli/test/ApiGwTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,32 @@ abstract class ApiGwTests extends BaseApiGwTests {
verifyMissingField(rr)
}

it should "api create should fail if action is not a web action" in {
val testName = "CLI_APIGWTEST_RO1"
val testbasepath = "/" + testName + "_bp"
val testrelpath = "/path"
val testnewrelpath = "/path_new"
val testurlop = "get"
val testapiname = testName + " API Name"
val actionName = testName + "_action"
try {
// Create the action for the API. It must be a "web-action" action.
val file = TestCLIUtils.getTestActionFilename(s"echo.js")
wsk.action.create(name = actionName, artifact = Some(file), expectedExitCode = createCode)

var rr = apiCreate(
basepath = Some(testbasepath),
relpath = Some(testrelpath),
operation = Some(testurlop),
action = Some(actionName),
apiname = Some(testapiname),
expectedExitCode = ERROR_EXIT)
rr.stderr should include(s"""Action '/_/${actionName}' is not a web action. Issue 'wsk action update "${actionName}" --web true' to convert the action to a web action.""")
} finally {
wsk.action.delete(name = actionName, expectedExitCode = DONTCARE_EXIT)
}
}

it should "verify full list output" in {
val testName = "CLI_APIGWTEST_RO1"
val testbasepath = "/" + testName + "_bp"
Expand Down
13 changes: 13 additions & 0 deletions tests/src/test/scala/whisk/core/cli/test/WskBasicUsageTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,19 @@ class WskBasicUsageTests extends TestHelpers with WskTestHelpers {
}
}

it should "invoke an action that exits during run and check that the activation summary has the name in quoted" in withAssetCleaner(wskprops) {
(wp, assetHelper) =>
val name = "helloRunSummary"
assetHelper.withCleaner(wsk.action, name) { (action, _) =>
action.create(name, Some(TestCLIUtils.getTestActionFilename("hello.js")))
}
val activationId = wsk.action.invoke(name).stdout.split("with id ")(1).trim
wsk.activation.waitForActivation(activationId)
val activationResponse = wsk.activation.get(Some(activationId), summary = Some(true))
activationResponse.stdout should include(s"""activation result for '/guest/${name}'""")
}


it should "retrieve the last activation using --last flag" in withAssetCleaner(wskprops) { (wp, assetHelper) =>
val auth: Seq[String] = Seq("--auth", wskprops.authKey)
val includeStr = "hello, undefined!"
Expand Down

0 comments on commit e8cfa2e

Please sign in to comment.