|
| 1 | +/* |
| 2 | + * Copyright 2018 IBM Corporation |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +// |
| 18 | +// tests that create an action and test that it shows up in the list UI |
| 19 | +// this test also covers toggling the sidecar |
| 20 | +// |
| 21 | +const common = require('../../../lib/common'), |
| 22 | + openwhisk = require('../../../lib/openwhisk'), |
| 23 | + ui = require('../../../lib/ui'), |
| 24 | + assert = require('assert'), |
| 25 | + keys = ui.keys, |
| 26 | + cli = ui.cli, |
| 27 | + sidecar = ui.sidecar, |
| 28 | + actionName1 = `foo1-${new Date().getTime()}`, |
| 29 | + actionName2 = `foo2-${new Date().getTime()}` |
| 30 | + |
| 31 | +describe('wsk activation result and wsk activation logs', function() { |
| 32 | + before(common.before(this)) |
| 33 | + after(common.after(this)) |
| 34 | + |
| 35 | + it('should have an active repl', () => cli.waitForRepl(this.app)) |
| 36 | + |
| 37 | + // create an action |
| 38 | + it(`should create an action ${actionName1}`, () => cli.do(`create ${actionName1} ./data/foo.js`, this.app) |
| 39 | + .then(cli.expectOK) |
| 40 | + .then(sidecar.expectOpen) |
| 41 | + .then(sidecar.expectShowing(actionName1)) |
| 42 | + .catch(common.oops(this))) |
| 43 | + |
| 44 | + it(`should async that action then show its logs and result`, () => cli.do(`async ${actionName1}`, this.app) |
| 45 | + .then(cli.expectOKWithCustom(cli.makeCustom('.activationId', ''))) |
| 46 | + .then(selector => this.app.client.getText(selector) |
| 47 | + .then(activationId => cli.do(`wsk activation logs ${activationId}`, this.app) |
| 48 | + .then(() => sidecar.expectOpen(this.app)) |
| 49 | + .then(sidecar.expectShowing(actionName1, activationId)) |
| 50 | + .then(sidecar.expectMode('logs')) |
| 51 | + .then(() => this.app.restart()) |
| 52 | + .then(() => cli.do(`activation logs ${activationId}`, this.app)) |
| 53 | + .then(() => sidecar.expectOpen(this.app)) |
| 54 | + .then(sidecar.expectShowing(actionName1, activationId)) |
| 55 | + .then(sidecar.expectMode('logs')) |
| 56 | + .then(() => this.app.restart()) |
| 57 | + .then(() => cli.do(`activation result ${activationId}`, this.app)) |
| 58 | + .then(() => sidecar.expectOpen(this.app)) |
| 59 | + .then(sidecar.expectShowing(actionName1, activationId)) |
| 60 | + .then(sidecar.expectMode('result')))) |
| 61 | + .catch(common.oops(this))) |
| 62 | +}) |
0 commit comments