forked from nfroidure/whook
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request nfroidure#32 from nfroidure/refactor/commands
Refactor/commands
- Loading branch information
Showing
47 changed files
with
1,543 additions
and
414 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
packages/whook-cli/src/commands/__snapshots__/config.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`configCommand should fail with no result 1`] = ` | ||
Object { | ||
"errorCode": "E_NO_RESULT", | ||
"errorParams": Array [ | ||
"MYSQL", | ||
"nothing_here", | ||
], | ||
"logCalls": Array [ | ||
Array [ | ||
"error", | ||
"Could not find any results for nothing_here", | ||
], | ||
], | ||
} | ||
`; | ||
|
||
exports[`configCommand should fail with unexisting config name 1`] = ` | ||
Object { | ||
"errorCode": "E_NO_CONFIG", | ||
"errorParams": Array [ | ||
"DOES_NOT_EXIST", | ||
], | ||
"logCalls": Array [ | ||
Array [ | ||
"error", | ||
"No config found for DOES_NOT_EXIST", | ||
], | ||
], | ||
} | ||
`; | ||
|
||
exports[`configCommand should work with an unexisting config but a default value 1`] = ` | ||
Object { | ||
"logCalls": Array [ | ||
Array [ | ||
"error", | ||
"No config found for DOES_NOT_EXIST", | ||
], | ||
Array [ | ||
"info", | ||
"undefined", | ||
], | ||
], | ||
"result": undefined, | ||
} | ||
`; | ||
|
||
exports[`configCommand should work with no query at all 1`] = ` | ||
Object { | ||
"logCalls": Array [ | ||
Array [ | ||
"info", | ||
"{\\"auth\\":{\\"username\\":\\"root\\"},\\"version\\":\\"2.1.1\\"}", | ||
], | ||
], | ||
"result": undefined, | ||
} | ||
`; | ||
|
||
exports[`configCommand should work with no result but a default value 1`] = ` | ||
Object { | ||
"logCalls": Array [ | ||
Array [ | ||
"error", | ||
"Could not find any results for nothing_here", | ||
], | ||
Array [ | ||
"info", | ||
"\\"v8\\"", | ||
], | ||
], | ||
"result": undefined, | ||
} | ||
`; | ||
|
||
exports[`configCommand should work with one value 1`] = ` | ||
Object { | ||
"logCalls": Array [ | ||
Array [ | ||
"info", | ||
"\\"root\\"", | ||
], | ||
], | ||
"result": undefined, | ||
} | ||
`; | ||
|
||
exports[`configCommand should work with several values 1`] = ` | ||
Object { | ||
"logCalls": Array [ | ||
Array [ | ||
"info", | ||
"\\"root\\"", | ||
], | ||
], | ||
"result": undefined, | ||
} | ||
`; |
35 changes: 35 additions & 0 deletions
35
packages/whook-cli/src/commands/__snapshots__/env.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`envCommand should fail with no value 1`] = ` | ||
Object { | ||
"errorCode": "E_NO_ENV_VALUE", | ||
"errorParams": Array [ | ||
"NODE_ENV", | ||
], | ||
"logCalls": Array [], | ||
} | ||
`; | ||
|
||
exports[`envCommand should work 1`] = ` | ||
Object { | ||
"logCalls": Array [ | ||
Array [ | ||
"info", | ||
"test", | ||
], | ||
], | ||
"result": undefined, | ||
} | ||
`; | ||
|
||
exports[`envCommand should work with a default value 1`] = ` | ||
Object { | ||
"logCalls": Array [ | ||
Array [ | ||
"info", | ||
"lol", | ||
], | ||
], | ||
"result": undefined, | ||
} | ||
`; |
114 changes: 114 additions & 0 deletions
114
packages/whook-cli/src/commands/__snapshots__/handler.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`handlerCommand should fail with a failing handler 1`] = ` | ||
Object { | ||
"errorCode": "E_UNEXPECTED_SUCCESS", | ||
"errorParams": Array [], | ||
"injectorCalls": Array [ | ||
Array [ | ||
Array [ | ||
"putEcho", | ||
], | ||
], | ||
], | ||
"logCalls": Array [ | ||
Array [ | ||
"debug", | ||
"handler", | ||
"putEcho", | ||
], | ||
Array [ | ||
"debug", | ||
"parameters", | ||
Object { | ||
"body": Object { | ||
"echo": "YOLO!", | ||
}, | ||
}, | ||
], | ||
Array [ | ||
"error", | ||
"Got an error while running the handler.", | ||
], | ||
], | ||
} | ||
`; | ||
|
||
exports[`handlerCommand should fail with non JSON parameters 1`] = ` | ||
Object { | ||
"errorCode": "E_BAD_PARAMETERS", | ||
"errorParams": Array [ | ||
"{\\"body: {\\"echo\\": \\"YOLO!\\"} }", | ||
"Unexpected token e in JSON at position 10", | ||
], | ||
"injectorCalls": Array [], | ||
"logCalls": Array [], | ||
} | ||
`; | ||
|
||
exports[`handlerCommand should work with all parameters 1`] = ` | ||
Object { | ||
"injectorCalls": Array [ | ||
Array [ | ||
Array [ | ||
"putEcho", | ||
], | ||
], | ||
], | ||
"logCalls": Array [ | ||
Array [ | ||
"debug", | ||
"handler", | ||
"putEcho", | ||
], | ||
Array [ | ||
"debug", | ||
"parameters", | ||
Object { | ||
"body": Object { | ||
"echo": "YOLO!", | ||
}, | ||
}, | ||
], | ||
Array [ | ||
"info", | ||
"{ | ||
\\"status\\": 200, | ||
\\"body\\": { | ||
\\"echo\\": \\"YOLO!\\" | ||
} | ||
}", | ||
], | ||
], | ||
} | ||
`; | ||
|
||
exports[`handlerCommand should work with handler only 1`] = ` | ||
Object { | ||
"injectorCalls": Array [ | ||
Array [ | ||
Array [ | ||
"getPing", | ||
], | ||
], | ||
], | ||
"logCalls": Array [ | ||
Array [ | ||
"debug", | ||
"handler", | ||
"getPing", | ||
], | ||
Array [ | ||
"debug", | ||
"parameters", | ||
Object {}, | ||
], | ||
Array [ | ||
"info", | ||
"{ | ||
\\"status\\": 200 | ||
}", | ||
], | ||
], | ||
} | ||
`; |
110 changes: 110 additions & 0 deletions
110
packages/whook-cli/src/commands/__snapshots__/ls.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`lsCommand should work with no plugin 1`] = ` | ||
Object { | ||
"logCalls": Array [], | ||
"readDirCalls": Array [], | ||
"requireCalls": Array [], | ||
"result": undefined, | ||
} | ||
`; | ||
|
||
exports[`lsCommand should work with some plugins 1`] = ` | ||
Object { | ||
"logCalls": Array [ | ||
Array [ | ||
"debug", | ||
"✅ - No commands folder found at path \${pluginPath}", | ||
], | ||
Array [ | ||
"info", | ||
" | ||
# Provided by \\"@whook/cli\\": 2 commands", | ||
], | ||
Array [ | ||
"info", | ||
"- ls: Print available commands", | ||
], | ||
Array [ | ||
"info", | ||
"- env: A command printing env values", | ||
], | ||
Array [ | ||
"info", | ||
" | ||
# Provided by \\"@whook/whook\\": none", | ||
], | ||
], | ||
"readDirCalls": Array [ | ||
Array [ | ||
"/var/lib/node/node_modules/@whook/cli/dist/commands", | ||
], | ||
Array [ | ||
"/var/lib/node/node_modules/@whook/lol/dist/commands", | ||
], | ||
], | ||
"requireCalls": Array [ | ||
Array [ | ||
"/var/lib/node/node_modules/@whook/cli/dist/commands/ls", | ||
], | ||
Array [ | ||
"/var/lib/node/node_modules/@whook/cli/dist/commands/env", | ||
], | ||
], | ||
} | ||
`; | ||
|
||
exports[`lsCommand should work with some plugins and a verbose output 1`] = ` | ||
Object { | ||
"logCalls": Array [ | ||
Array [ | ||
"debug", | ||
"✅ - No commands folder found at path \${pluginPath}", | ||
], | ||
Array [ | ||
"info", | ||
" | ||
# Provided by \\"@whook/cli\\": 2 commands | ||
", | ||
], | ||
Array [ | ||
"info", | ||
"- ls: Print available commands | ||
$ whook ls | ||
", | ||
], | ||
Array [ | ||
"info", | ||
"- env: A command printing env values | ||
$ whook env --name NODE_ENV --default \\"default value\\" | ||
", | ||
], | ||
Array [ | ||
"info", | ||
" | ||
# Provided by \\"@whook/whook\\": none | ||
", | ||
], | ||
], | ||
"readDirCalls": Array [ | ||
Array [ | ||
"/var/lib/node/node_modules/@whook/cli/dist/commands", | ||
], | ||
Array [ | ||
"/var/lib/node/node_modules/@whook/lol/dist/commands", | ||
], | ||
], | ||
"requireCalls": Array [ | ||
Array [ | ||
"/var/lib/node/node_modules/@whook/cli/dist/commands/ls", | ||
], | ||
Array [ | ||
"/var/lib/node/node_modules/@whook/cli/dist/commands/env", | ||
], | ||
], | ||
} | ||
`; |
Oops, something went wrong.