Skip to content

Commit

Permalink
feat(@whook/cli): allow to inspect injector results
Browse files Browse the repository at this point in the history
  • Loading branch information
nfroidure committed Mar 26, 2020
1 parent 18af154 commit 06b2cf4
Show file tree
Hide file tree
Showing 7 changed files with 644 additions and 21 deletions.
25 changes: 8 additions & 17 deletions packages/whook-cli/src/commands/__snapshots__/config.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`configCommand should fail with no result 1`] = `
exports[`configCommand should fail with no result 2`] = `
Object {
"errorCode": "E_NO_RESULT",
"errorParams": Array [
"MYSQL",
"nothing_here",
],
"logCalls": Array [
Array [
"error",
Expand All @@ -19,12 +14,8 @@ Object {
}
`;

exports[`configCommand should fail with unexisting config name 1`] = `
exports[`configCommand should fail with unexisting config name 2`] = `
Object {
"errorCode": "E_NO_CONFIG",
"errorParams": Array [
"DOES_NOT_EXIST",
],
"logCalls": Array [
Array [
"error",
Expand All @@ -37,7 +28,7 @@ Object {
}
`;

exports[`configCommand should work with an unexisting config but a default value 1`] = `
exports[`configCommand should work with an unexisting config but a default value 2`] = `
Object {
"logCalls": Array [
Array [
Expand All @@ -46,7 +37,7 @@ Object {
],
Array [
"info",
"undefined",
"\\"v8\\"",
],
],
"promptArgsCalls": Array [
Expand All @@ -56,7 +47,7 @@ Object {
}
`;

exports[`configCommand should work with no query at all 1`] = `
exports[`configCommand should work with no query at all 2`] = `
Object {
"logCalls": Array [
Array [
Expand All @@ -71,7 +62,7 @@ Object {
}
`;

exports[`configCommand should work with no result but a default value 1`] = `
exports[`configCommand should work with no result but a default value 2`] = `
Object {
"logCalls": Array [
Array [
Expand All @@ -90,7 +81,7 @@ Object {
}
`;

exports[`configCommand should work with one value 1`] = `
exports[`configCommand should work with one value 2`] = `
Object {
"logCalls": Array [
Array [
Expand All @@ -105,7 +96,7 @@ Object {
}
`;

exports[`configCommand should work with several values 1`] = `
exports[`configCommand should work with several values 2`] = `
Object {
"logCalls": Array [
Array [
Expand Down
169 changes: 169 additions & 0 deletions packages/whook-cli/src/commands/__snapshots__/inspect.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`inspectCommand should fail with no result 2`] = `
Object {
"injectorCalls": Array [
Array [
Array [
"MYSQL",
],
],
],
"logCalls": Array [
Array [
"error",
"Could not find any results for nothing_here",
],
],
"promptArgsCalls": Array [
Array [],
],
}
`;

exports[`inspectCommand should fail with unexisting config name 2`] = `
Object {
"injectorCalls": Array [
Array [
Array [
"DOES_NOT_EXIST",
],
],
],
"logCalls": Array [
Array [
"error",
"No service found for DOES_NOT_EXIST",
],
Array [
"error",
"try debugging with the DEBUG=whook env.",
],
],
"promptArgsCalls": Array [
Array [],
],
}
`;

exports[`inspectCommand should work with an unexisting config but a default value 2`] = `
Object {
"injectorCalls": Array [
Array [
Array [
"DOES_NOT_EXIST",
],
],
],
"logCalls": Array [
Array [
"error",
"No service found for DOES_NOT_EXIST",
],
Array [
"error",
"try debugging with the DEBUG=whook env.",
],
Array [
"info",
"\\"v8\\"",
],
],
"promptArgsCalls": Array [
Array [],
],
"result": undefined,
}
`;

exports[`inspectCommand should work with no query at all 2`] = `
Object {
"injectorCalls": Array [
Array [
Array [
"MYSQL",
],
],
],
"logCalls": Array [
Array [
"info",
"{\\"auth\\":{\\"username\\":\\"root\\"},\\"version\\":\\"2.1.1\\"}",
],
],
"promptArgsCalls": Array [
Array [],
],
"result": undefined,
}
`;

exports[`inspectCommand should work with no result but a default value 2`] = `
Object {
"injectorCalls": Array [
Array [
Array [
"MYSQL",
],
],
],
"logCalls": Array [
Array [
"error",
"Could not find any results for nothing_here",
],
Array [
"info",
"\\"v8\\"",
],
],
"promptArgsCalls": Array [
Array [],
],
"result": undefined,
}
`;

exports[`inspectCommand should work with one value 2`] = `
Object {
"injectorCalls": Array [
Array [
Array [
"MYSQL",
],
],
],
"logCalls": Array [
Array [
"info",
"\\"root\\"",
],
],
"promptArgsCalls": Array [
Array [],
],
"result": undefined,
}
`;

exports[`inspectCommand should work with several values 2`] = `
Object {
"injectorCalls": Array [
Array [
Array [
"MYSQL",
],
],
],
"logCalls": Array [
Array [
"info",
"\\"root\\"",
],
],
"promptArgsCalls": Array [
Array [],
],
"result": undefined,
}
`;
79 changes: 79 additions & 0 deletions packages/whook-cli/src/commands/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ describe('configCommand', () => {
});
const result = await configCommand();

expect({
output: log.mock.calls.filter(([type]) => type === 'info'),
}).toMatchInlineSnapshot(`
Object {
"output": Array [
Array [
"info",
"{\\"auth\\":{\\"username\\":\\"root\\"},\\"version\\":\\"2.1.1\\"}",
],
],
}
`);
expect({
result,
promptArgsCalls: promptArgs.mock.calls,
Expand All @@ -52,6 +64,18 @@ describe('configCommand', () => {
});
const result = await configCommand();

expect({
output: log.mock.calls.filter(([type]) => type === 'info'),
}).toMatchInlineSnapshot(`
Object {
"output": Array [
Array [
"info",
"\\"root\\"",
],
],
}
`);
expect({
result,
promptArgsCalls: promptArgs.mock.calls,
Expand All @@ -73,6 +97,18 @@ describe('configCommand', () => {
});
const result = await configCommand();

expect({
output: log.mock.calls.filter(([type]) => type === 'info'),
}).toMatchInlineSnapshot(`
Object {
"output": Array [
Array [
"info",
"\\"root\\"",
],
],
}
`);
expect({
result,
promptArgsCalls: promptArgs.mock.calls,
Expand All @@ -94,6 +130,18 @@ describe('configCommand', () => {
});
const result = await configCommand();

expect({
output: log.mock.calls.filter(([type]) => type === 'info'),
}).toMatchInlineSnapshot(`
Object {
"output": Array [
Array [
"info",
"\\"v8\\"",
],
],
}
`);
expect({
result,
promptArgsCalls: promptArgs.mock.calls,
Expand All @@ -116,6 +164,18 @@ describe('configCommand', () => {
});
const result = await configCommand();

expect({
output: log.mock.calls.filter(([type]) => type === 'info'),
}).toMatchInlineSnapshot(`
Object {
"output": Array [
Array [
"info",
"\\"v8\\"",
],
],
}
`);
expect({
result,
promptArgsCalls: promptArgs.mock.calls,
Expand All @@ -142,6 +202,15 @@ describe('configCommand', () => {
expect({
errorCode: err.code,
errorParams: err.params,
}).toMatchInlineSnapshot(`
Object {
"errorCode": "E_NO_CONFIG",
"errorParams": Array [
"DOES_NOT_EXIST",
],
}
`);
expect({
promptArgsCalls: promptArgs.mock.calls,
logCalls: log.mock.calls.filter(args => 'stack' !== args[0]),
}).toMatchSnapshot();
Expand All @@ -168,6 +237,16 @@ describe('configCommand', () => {
expect({
errorCode: err.code,
errorParams: err.params,
}).toMatchInlineSnapshot(`
Object {
"errorCode": "E_NO_RESULT",
"errorParams": Array [
"MYSQL",
"nothing_here",
],
}
`);
expect({
promptArgsCalls: promptArgs.mock.calls,
logCalls: log.mock.calls.filter(args => 'stack' !== args[0]),
}).toMatchSnapshot();
Expand Down
Loading

0 comments on commit 06b2cf4

Please sign in to comment.