-
Notifications
You must be signed in to change notification settings - Fork 38
Updates after refactoring Connection constructor #45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Add in checks for when returnError is false in Toolkit.js. This is case occurs when a call from deprecated class goes through Toolkit.js. Instead of worrying about setting the flag on and off create a new Connection object when same config when returnError is false within the constructor. Then have proper checks for when to report the error.
Seems really weird to have a single |
Probably better to have three separate classes I would think. I think I combined them into CommandCall when I had the zeal of cutting down as much of the duplicated code in this project as possible. |
The current constructor for CommandCall accepts an object with the format: {
command: ' '
type: 'sh' || 'cl' || 'qsh',
[options]: {}
} command and type properties are required. So In Ideally, I would like to have I would like to have had |
Having 3 separate classes works too. The reason I did not go that route first was to keep things less verbose. If we went that route the classes themselves would be pretty thin for now. Maybe something like: class CLCommand {
constructor(command, options) {
if (!command || typeof command !== 'string') {
throw new Error('Command is required');
}
this.command = command;
if (options && typeof options === 'object') {
this.options = options;
}
}
toXML() {
.... code to generate and return xml
}
} The other 2 command classes would be similar |
I see now. In that case, I'd just merge those functions in to |
I really hate this |
We should consider refactoring and simplifying |
Agreed. I opened #46 to keep track of it. |
Merged (cl, sh, qsh) functions into Reverted back to use |
- class to maintain command types (sh, cl, qsh) see issue #24 - merge (sh, cl, qsh) code into toXml - add in some JSDoc annotations
- add CommandCall to exports - remove previous generateXml functions
- Use depd package to display deprecation warnings iConn Class - wrap getConnection() to call getTransportOptions - have setTimeout() print warning Use route (iSh, iCmd, iQsh) to use CommandCall
update returnTransports function - use single object to configure the Connection - add transportOptions to options in returnTransport add returnTrasportsDeprecated - transports using iConn used by depercated functional tests
Functional tests using deprecated class moved to: - test/functional/deprecated Unit tests using deprecated classes moved to: - test/unit/deprecated This was done to keep pre v1.0 tests around to ensure compatability. At some point we will stop supporting these in the future. Then we can simply git rm these two folders
Both unit and functional tests updated to use current non deprecated versions Unit Tests iConnUnit.js - remove setTimeout() test because method no longer exists Functional Tests - update run function callback to include error first - rename user -> username for options object
- consolidates all Toolkit methods into one test file - remove deprecated files
- iPgmFunctional -> ProgramCallFunctional - iSqlFunctional -> SqlCallFunctional - commandsFunctional -> CommandCallFunctional - iConnUnit -> ConnectionUnit - iPgmUnit -> ProgramCallUnit - iSqlUnit -> SqlCallunit
Changes to Toolkit.js
After refactoring Connection construct options were added to return an error on the user provided callback to
Connection.run()
.Toolkit.js
was previously updated with a632dbf. These changes do not take into account whenreturnError
is set to false.returnError
is to false wheniConn
class is used. This is because in prev.1.0
version errors were not returned. In that case run will only return XML output instead(error, output)
.Now with 4236059: added in checks for when
returnError
is false Toolkit.js. Within the constructor a new Connection based on the transport options from theconn
parameter is created whenreturnError
is false. This was done to avoid worrying about setting it back to on at some point and possible race conditions if the same connection object is used elsewhere.Added CommandCall Class
CommandCall
class was added to to maintain command types (sh, cl, qsh). Please view this issue for reasoning.Updated Deprecated.js
Updated unit/functional tests
Both unit and functional tests updated to use current non deprecated
versions.
Moved existing unit/functional tests:
Functional tests using deprecated class moved to
test/functional/deprecated
Unit tests using deprecated classes moved to
test/unit/deprecated
Added ToolkitFunctional.js
ToolkitFunctional.js