-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rewrite wsk basic tests #3103
Rewrite wsk basic tests #3103
Conversation
ac1835d
to
44808c8
Compare
44808c8
to
06f9236
Compare
Please provide a description about what this PR is supposed to solve and what's the intended change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix mutability aspects and some parsing which could make the tests clearer.
stdout should include regex (""""key":"a"""") | ||
stdout should include regex (""""value":"A"""") | ||
stdout should include regex (""""publish":true""") | ||
stdout should include regex (""""version":"0.0.2"""") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we parse the JSON response of the API and then assert on the parsed values? That would remove those whitespace issues alltogether.
result.getField("version") shouldBe "0.0.1" | ||
result.getFieldJsValue("publish").toString shouldBe "false" | ||
result.getFieldJsValue("binding").toString shouldBe "{}" | ||
result.getField("invalid") shouldBe "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Above tests should work like this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
case (value) => | ||
val fullName = fullEntityName(value) | ||
paramsList :+= JsString(fullName) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #2996 for comments on these parts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
49f5f94
to
7c02dff
Compare
7c02dff
to
2b7eee0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@houshengbo, what's the status of this PR?
2b7eee0
to
67b2f51
Compare
ActivationResult.serdes.read(removeCLIHeader(stderr).parseJson).response.result shouldBe Some { | ||
JsObject("error" -> JsObject("msg" -> "failed activation on purpose".toJson)) | ||
} | ||
val result = wsk.action.invoke(name, blocking = true, expectedExitCode = 502) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
502? Why not use the akka code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
stdout should include regex (""""version": "0.0.2"""") | ||
wsk.pkg.list().stdout should include(name) | ||
val pack = wsk.pkg.get(name) | ||
pack.getFieldJsValue("publish").toString shouldBe "true" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can remove toString and use shouldBe JsBoolean(true) also fyi.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
val stderr = wsk.pkg.create(name, expectedExitCode = CONFLICT).stderr | ||
stderr should include regex (s"""Unable to create package '$name': resource already exists \\(code \\d+\\)""") | ||
val stderr = wsk.pkg.create(name, expectedExitCode = Conflict.intValue).stderr | ||
stderr should include regex (s"""resource already exists""") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
many cases of s"""xxx"""
dont need string interpolation, and can just be "xxx"
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
.stdout should include regex (""""count": 3""") | ||
val result = wsk.action | ||
.invoke(name, Map("payload" -> "one two three".toJson), blocking = true, result = true) | ||
result.stdout should include regex (""""count":3""") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this check is weaker now - it should be:
result.stdout.parseJson.asJsObject shouldBe JsObject("count" -> JsNumber(3))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
} | ||
|
||
it should "list entities in default namespace" in { | ||
// use a fresh wsk props instance that is guaranteed to use | ||
// the default namespace | ||
wsk.namespace.get(expectedExitCode = SUCCESS_EXIT)(WskProps()).stdout should include("default") | ||
val result = wsk.namespace.get()(WskProps()).stdout | ||
result should include("actions") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about parsing the output and checking that it's a JsObject that includes these four fields, and each value is an JsArray.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will remove this test case, since get is not supported by REST implementation.
|
||
it should "not list entities with an invalid namespace" in { | ||
val namespace = "fakeNamespace" | ||
val stderr = wsk.namespace.get(Some(s"/${namespace}"), expectedExitCode = Forbidden.intValue).stderr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use action list as this will no longer work soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will remove this test case, since get is not supported by REST implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments.
eed4114
to
c03dbd3
Compare
@markusthoemmes can you update your review? |
Relaunched a PG: Playground3 1691. |
599e390
to
63e9aff
Compare
result.getField("name") shouldBe name | ||
result.getField("version") shouldBe "0.0.1" | ||
result.getFieldJsValue("publish") shouldBe JsBoolean(false) | ||
result.getFieldJsValue("binding").toString shouldBe "{}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
result.getFieldJsValue("binding") shouldBe JsObject()
?
result.getFieldJsValue("annotations").toString shouldBe "[]" | ||
result.getFieldJsValue("parameters") shouldBe JsArray( | ||
JsObject("key" -> JsString("payload"), "value" -> JsString("test"))) | ||
result.getFieldJsValue("limits").toString shouldBe "{}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think you can replace all the {} checks with JsObject()
requested changes already made.
This PR rewrites WskBasicTests.
63e9aff
to
1e84f61
Compare
This rewrites the test cases in WskBasicTests by implementing them in REST interface.