Skip to content

Commit b654a67

Browse files
committed
Added test cases for quoted strings.
1 parent 0fb150b commit b654a67

File tree

4 files changed

+121
-0
lines changed

4 files changed

+121
-0
lines changed

tests/src/test/scala/system/basic/WskConsoleTests.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,14 @@ abstract class WskConsoleTests extends TestHelpers with WskTestHelpers {
121121
}
122122
}
123123

124+
it should "invoke an action and poll activations and verify that action names are quoted." in withAssetCleaner(wskprops) {
125+
(wp, assetHelper) =>
126+
val name = "helloRunActivationPoll"
127+
assetHelper.withCleaner(wsk.action, name) { (action, _) =>
128+
action.create(name, Some(TestCLIUtils.getTestActionFilename("hello.js")))
129+
}
130+
val activationId = wsk.action.invoke(name)
131+
val pollResults = wsk.activation.console(duration = 5.second, actionName = Some(name))
132+
pollResults.stdout should include (s"""Activation: '${name}'""")
133+
}
124134
}

tests/src/test/scala/system/basic/WskSdkTests.scala

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ import common.Wsk
3131
import common.WskProps
3232
import common.WskTestHelpers
3333

34+
import scala.sys.process._
35+
3436
@RunWith(classOf[JUnitRunner])
3537
class WskSdkTests extends TestHelpers with WskTestHelpers {
3638

@@ -82,6 +84,76 @@ class WskSdkTests extends TestHelpers with WskTestHelpers {
8284
}
8385
}
8486

87+
it should "download docker sdk when blackbox.tar.gz exists, and docker name should be quoted in error." in {
88+
val fileName = "blackbox.tar.gz"
89+
val dir = File.createTempFile("wskinstall", ".tmp")
90+
dir.delete()
91+
dir.mkdir() should be(true)
92+
val file = new File(dir, fileName)
93+
file.createNewFile should be (true)
94+
try {
95+
wsk.cli(wskprops.overrides ++ Seq("sdk", "install", "docker"),
96+
workingDir = dir,
97+
expectedExitCode = 1).stderr should include(
98+
s"""The file '${fileName}' already exists. Delete it and retry.""")
99+
} finally {
100+
file.delete()
101+
FileUtils.deleteDirectory(dir)
102+
}
103+
}
104+
105+
it should "download ios sdk when OpenWhiskIOSStarterApp.zip exists, and ios name should be quoted in error." in {
106+
val fileName = "OpenWhiskIOSStarterApp.zip"
107+
val dir = File.createTempFile("wskinstall", ".tmp")
108+
dir.delete()
109+
dir.mkdir() should be(true)
110+
val file = new File(dir, fileName)
111+
file.createNewFile should be (true)
112+
try {
113+
wsk.cli(wskprops.overrides ++ Seq("sdk", "install", "ios"),
114+
workingDir = dir,
115+
expectedExitCode = 1).stderr should include(
116+
s"""The file '${fileName}' already exists. Delete it and retry.""")
117+
} finally {
118+
file.delete()
119+
FileUtils.deleteDirectory(dir)
120+
}
121+
}
122+
123+
it should "download ios sdk, check filename is quoted in error when create fails." in {
124+
val fileName = "OpenWhiskIOSStarterApp.zip"
125+
val dir = File.createTempFile("wskinstall", ".tmp")
126+
dir.delete()
127+
dir.mkdir() should be(true)
128+
Seq("chmod", "555", dir.getAbsolutePath).!!
129+
try {
130+
wsk.cli(wskprops.overrides ++ Seq("sdk", "install", "ios"),
131+
workingDir = dir,
132+
expectedExitCode = 1).stderr should include(
133+
s"""Error creating SDK file '${fileName}':""")
134+
} finally {
135+
FileUtils.deleteDirectory(dir)
136+
}
137+
}
138+
139+
it should "download docker sdk twice, check directory is quoted in error when create fails." in {
140+
val dir = File.createTempFile("wskinstall", ".tmp")
141+
dir.delete()
142+
dir.mkdir() should be(true)
143+
try {
144+
wsk.cli(wskprops.overrides ++ Seq("sdk", "install", "docker"),
145+
workingDir = dir).stdout should include(
146+
s"""The docker skeleton is now installed at the current directory.""")
147+
148+
wsk.cli(wskprops.overrides ++ Seq("sdk", "install", "docker"),
149+
workingDir = dir,
150+
expectedExitCode = 1).stderr should include(
151+
s"""The directory 'dockerSkeleton' already exists. Delete it and retry.""")
152+
} finally {
153+
FileUtils.deleteDirectory(dir)
154+
}
155+
}
156+
85157
it should "download iOS sdk" in {
86158
val dir = File.createTempFile("wskinstall", ".tmp")
87159
dir.delete()

tests/src/test/scala/whisk/core/cli/test/ApiGwTests.scala

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,32 @@ abstract class ApiGwTests extends BaseApiGwTests {
262262
verifyMissingField(rr)
263263
}
264264

265+
it should "api create should fail if action is not a web action" in {
266+
val testName = "CLI_APIGWTEST_RO1"
267+
val testbasepath = "/" + testName + "_bp"
268+
val testrelpath = "/path"
269+
val testnewrelpath = "/path_new"
270+
val testurlop = "get"
271+
val testapiname = testName + " API Name"
272+
val actionName = testName + "_action"
273+
try {
274+
// Create the action for the API. It must be a "web-action" action.
275+
val file = TestCLIUtils.getTestActionFilename(s"echo.js")
276+
wsk.action.create(name = actionName, artifact = Some(file), expectedExitCode = createCode)
277+
278+
var rr = apiCreate(
279+
basepath = Some(testbasepath),
280+
relpath = Some(testrelpath),
281+
operation = Some(testurlop),
282+
action = Some(actionName),
283+
apiname = Some(testapiname),
284+
expectedExitCode = ERROR_EXIT)
285+
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.""")
286+
} finally {
287+
wsk.action.delete(name = actionName, expectedExitCode = DONTCARE_EXIT)
288+
}
289+
}
290+
265291
it should "verify full list output" in {
266292
val testName = "CLI_APIGWTEST_RO1"
267293
val testbasepath = "/" + testName + "_bp"

tests/src/test/scala/whisk/core/cli/test/WskBasicUsageTests.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,19 @@ class WskBasicUsageTests extends TestHelpers with WskTestHelpers {
275275
}
276276
}
277277

278+
it should "invoke an action that exits during run and check that the activation summary has the name in quoted" in withAssetCleaner(wskprops) {
279+
(wp, assetHelper) =>
280+
val name = "helloRunSummary"
281+
assetHelper.withCleaner(wsk.action, name) { (action, _) =>
282+
action.create(name, Some(TestCLIUtils.getTestActionFilename("hello.js")))
283+
}
284+
val activationId = wsk.action.invoke(name).stdout.split("with id ")(1).trim
285+
wsk.activation.waitForActivation(activationId)
286+
val activationResponse = wsk.activation.get(Some(activationId), summary = Some(true))
287+
activationResponse.stdout should include(s"""activation result for '/guest/${name}'""")
288+
}
289+
290+
278291
it should "retrieve the last activation using --last flag" in withAssetCleaner(wskprops) { (wp, assetHelper) =>
279292
val auth: Seq[String] = Seq("--auth", wskprops.authKey)
280293
val includeStr = "hello, undefined!"

0 commit comments

Comments
 (0)