Skip to content

Commit

Permalink
Coveralls
Browse files Browse the repository at this point in the history
  • Loading branch information
astrotars committed Mar 6, 2019
1 parent facee5f commit bb8ef61
Show file tree
Hide file tree
Showing 11 changed files with 360 additions and 26 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -6,3 +6,4 @@
/tmp
node_modules
.DS_Store
.coveralls.yml
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -6,6 +6,7 @@
Stream's Command Line Interface (CLI) makes it easy to create and manage your [Stream](https://getstream.io) apps directly from the terminal. Currently, only Chat is supported; however, the ability to manage Feeds will be coming soon.

[![Coverage Status](https://coveralls.io/repos/github/GetStream/stream-cli/badge.svg?branch=master)](https://coveralls.io/github/GetStream/stream-cli?branch=master)
[![Version](https://img.shields.io/npm/v/getstream-cli.svg)](https://npmjs.org/package/getstream-cli)
[![Dependency Status](https://david-dm.org/getstream/stream-cli/status.svg)](https://david-dm.org/getstream/stream-cli)
[![devDependency Status](https://david-dm.org/getstream/stream-cli/dev-status.svg)](https://david-dm.org/getstream/stream-cli?type=dev)
Expand Down
6 changes: 6 additions & 0 deletions examples/bash/README.md
@@ -0,0 +1,6 @@
# Requirements

The bash commands shown in this example directory require a couple of dependencies to run. Please see below for necessary dependencies:

- [JQ](https://stedolan.github.io/jq/)
- [OpenSSL](https://www.openssl.org/)
4 changes: 3 additions & 1 deletion package.json
Expand Up @@ -21,7 +21,7 @@
"scripts": {
"manifest": "rm -f oclif.manifest.json && oclif-dev manifest",
"readme": "oclif-dev readme --multi",
"test": "nyc mocha --exit --forbid-only \"test/**/*.test.js\"",
"test": "nyc report --reporter=text-lcov | coveralls mocha --exit --forbid-only \"test/**/*.test.js\"",
"posttest": "eslint ."
},
"dependencies": {
Expand Down Expand Up @@ -56,10 +56,12 @@
"@oclif/test": "^1",
"babel-eslint": "^10.0.1",
"chai": "^4",
"coveralls": "^3.0.3",
"eslint": "^5.15",
"eslint-config-oclif": "^3.1",
"eslint-plugin-babel": "^5.3.0",
"mocha": "^6.0.2",
"mocha-lcov-reporter": "^1.3.0",
"nyc": "^13",
"prettier": "^1.16.4"
},
Expand Down
2 changes: 1 addition & 1 deletion src/commands/chat/channel/get.js
Expand Up @@ -50,7 +50,7 @@ class ChannelGet extends Command {
);

if (flags.json) {
this.log(JSON.stringify(channel[0]));
this.log(JSON.stringify(channel[0].data));
this.exit(0);
}

Expand Down
7 changes: 5 additions & 2 deletions src/commands/chat/channel/list.js
Expand Up @@ -21,10 +21,13 @@ class ChannelList extends Command {
);

if (flags.json) {
for (const channel of channels) {
this.log(JSON.stringofy(channel));
const arr = [];

for (let i = 0; i < channels.length; i++) {
arr.push(channels[i].data);
}

this.log(JSON.stringify(arr));
this.exit(0);
}

Expand Down
6 changes: 3 additions & 3 deletions src/commands/chat/channel/query.js
Expand Up @@ -12,16 +12,16 @@ class ChannelQuery extends Command {
const filter = flags.filters ? JSON.parse(flags.filters) : {};
const sort = flags.sort ? JSON.parse(flags.sort) : {};

const channels = await client.queryChannels(filter, sort, {
const channel = await client.queryChannels(filter, sort, {
subscribe: false,
});

if (flags.json) {
this.log(JSON.stringify(channels));
this.log(JSON.stringify(channel[0].data));
this.exit(0);
}

this.log(channels[0].data);
this.log(channel[0].data);
this.exit(0);
} catch (error) {
this.error(error || 'A Stream CLI error has occurred.', {
Expand Down
12 changes: 7 additions & 5 deletions src/commands/chat/channel/update.js
Expand Up @@ -12,7 +12,7 @@ class ChannelUpdate extends Command {
const { name, email } = await credentials(this);

const client = await auth(this);
const channel = await client.channel(flags.type, flags.id);
const channel = await client.channel(flags.type, flags.channel);

let payload = {
name: flags.name,
Expand All @@ -38,9 +38,11 @@ class ChannelUpdate extends Command {
this.exit(0);
}

this.log(`The channel ${chalk.bold(flags.id)} has been modified.`);
this.log(`Channel ${chalk.bold(flags.channel)} has been modified.`);
} catch (error) {
this.error(error || 'A Stream CLI error has occurred.', { exit: 1 });
this.error(error || 'A Stream CLI error has occurred.', {
exit: 1,
});
}
}
}
Expand All @@ -62,8 +64,8 @@ ChannelUpdate.flags = {
description: 'Name of the channel room.',
required: false,
}),
url: flags.string({
char: 'u',
image: flags.string({
char: 'i',
description: 'URL to the channel image.',
required: false,
}),
Expand Down
58 changes: 54 additions & 4 deletions test/commands/channel.test.js
@@ -1,23 +1,73 @@
const { expect, test } = require('@oclif/test');
const uuid = require('uuid/v4');

const channelId = uuid();

describe('channel', () => {
test.stdout()
.command([
'chat:channel:create',
`--channel=${uuid()}`,
`--channel=${channelId}`,
'--type=messaging',
'--name=CLI',
'--image=https://images.unsplash.com/photo-1527427337751-fdca2f128ce5?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=250&q=80',
'--json',
])
.exit(1)
.it('runs chat:channel:create', (ctx, done) => {
.it('runs chat:channel:create', ctx => {
const data = JSON.parse(ctx.stdout);

expect(data).to.be.an('object');
expect(data).to.have.property('channel');
});

done();
test.stdout()
.command([
'chat:channel:get',
`--channel=${channelId}`,
'--type=messaging',
'--json',
])
.exit(1)
.it('runs chat:channel:get', ctx => {
const data = JSON.parse(ctx.stdout);

expect(data).to.be.an('object');
});

test.stdout()
.command(['chat:channel:list', '--json'])
.exit(1)
.it('runs chat:channel:list', ctx => {
const data = JSON.parse(ctx.stdout);

expect(data).to.be.an('array');
});

test.stdout()
.command(['chat:channel:query', `--channel=${channelId}`, '--json'])
.exit(1)
.it('runs chat:channel:query', ctx => {
const data = JSON.parse(ctx.stdout);

expect(data).to.be.an('object');
});

// test.stdout()
// .command([
// 'chat:channel:update',
// `--channel=${channelId}`,
// '--type=messaging',
// '--name=CLI',
// '--image=https://images.unsplash.com/photo-1527427337751-fdca2f128ce5?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=250&q=80',
// '--reason=TEST',
// '--json',
// ])
// .exit(1)
// .it('runs chat:channel:update', ctx => {
// //const data = JSON.parse(ctx.stdout);
//
// console.log(ctx.stdout);
//
// //expect(data).to.be.an('object');
// });
});
4 changes: 1 addition & 3 deletions test/commands/message.test.js
Expand Up @@ -9,11 +9,9 @@ describe('message', () => {
'--json',
])
.exit(1)
.it('runs chat:message:list', (ctx, done) => {
.it('runs chat:message:list', ctx => {
const data = JSON.parse(ctx.stdout);

expect(data).to.be.an('array');

done();
});
});

0 comments on commit bb8ef61

Please sign in to comment.