Skip to content

Commit

Permalink
Check error equality
Browse files Browse the repository at this point in the history
  • Loading branch information
godu committed Nov 17, 2016
1 parent 0dc7ead commit 4419355
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
11 changes: 5 additions & 6 deletions src/build-index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import {
assign,
cond,
constant,
flatMap,
get,
getOr,
Expand All @@ -18,10 +16,11 @@ const buildIndex = (index, node) => {
const value = get(index, node.value);

return pipe(
cond([
[get('dir'), getOr([], 'nodes')],
[constant(true), constant([])]
]),
_node => {
if (get('dir', _node))
return getOr([], 'nodes', _node);
return [];
},
flatMap(function(child) {
return buildIndex(index, child);
}),
Expand Down
4 changes: 2 additions & 2 deletions src/util/test/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ test('should throw error on directory sync if etcd throw unknown error', async t
t.fail();
}
catch (err) {
t.pass();
t.is(err, UnknownError);
}
});

Expand Down Expand Up @@ -140,7 +140,7 @@ test('should throw error on file sync if etcd throw unknown error', async t => {
t.fail();
}
catch (err) {
t.pass();
t.is(err, UnknownError);
}
});

Expand Down
5 changes: 3 additions & 2 deletions src/util/test/etcd.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,12 @@ const headers = () => ({'content-type': 'application/json'});

test(`${title} raise error`, async t => {
t.plan(2);
const TestError = new Error();
try {
await fn$({
[fn]: (..._argz) => {
const cb = _argz.pop();
cb(new Error('za'));
cb(TestError);
return {
abort: () => {
t.pass();
Expand All @@ -122,7 +123,7 @@ const headers = () => ({'content-type': 'application/json'});
t.fail();
}
catch (err) {
t.pass();
t.is(err, TestError);
}
});
});
Expand Down

0 comments on commit 4419355

Please sign in to comment.