-
Notifications
You must be signed in to change notification settings - Fork 7
Test of the inmemory db module #9
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
327e1ab to
743b91f
Compare
jacekkopecky
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mostly just polishing
| @@ -0,0 +1,5 @@ | |||
| /* eslint-disable */ | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this file shouldn't be necessary, please remove it
| "forever": "node_modules/.bin/nodemon -i examples/webpages/ examples/server", | ||
| "initsql": "mysql -u root -p < examples/sql_init.sql" | ||
| "initsql": "mysql -u root -p < examples/sql_init.sql", | ||
| "test": "node ./node_modules/qunit/bin/cli.js -c ./examples/index.js -t ./examples/test.js | cat" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this line above uses that index.js; let's hope the -c parameter it's optional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so we can give -c ./examples/model-inmemory.js instead of the file above which is no longer necessary
| "express": "^4.16.2", | ||
| "multer": "^1.3.0", | ||
| "mysql2": "^1.5.1" | ||
| "mysql2": "^1.5.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't need this chunk with node-fetch and jshintConfig
|
|
||
| const db = require(dir + pathInMemory); | ||
|
|
||
| test( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't need this test because two lines above we require the module, which has to read the file
|
|
||
| const dir = './'; | ||
| const pathInMemory = 'model-inmemory.js'; | ||
| const pathServer = 'server.js'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please drop dir, pathInMemory, and pathServer, we shouldn't need them
|
|
||
| try { | ||
| await db.uploadPicture(picture, 'testTitle', 'testAuthor'); | ||
| ok(false, 'It didn\'t throw anything.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make the message negative: uploadPicture should have thrown an exception; and same below for delete
| await db.uploadPicture(picture, 'testTitle', 'testAuthor'); | ||
| ok(false, 'It didn\'t throw anything.'); | ||
| } catch (e) { | ||
| ok(e[0] === 'failed to move incoming file', 'It threw the right exception.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make the message explanatory: say what exception you're expecting and maybe why
| path: pathImage + '/webpages/img/toDelete2.png', | ||
| }; | ||
|
|
||
| try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a comment about what the rest is doing
| ], | ||
| 'The picture was deleted.', | ||
| ); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can also check that the FS doesn't contain the picture you created for [5]
| await db.uploadPicture(picture, 'testTitle', 'testAuthor'), | ||
| { id: 5, title: 'testTitle', file: '/img/toDelete.png' }, | ||
| 'The picture was correctly uploaded.', | ||
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can also check the picture was correctly moved
|
closed in favour of #12 |
We have created tests for the file model-inmemory.js :
listPicturesthat are testing every case of the switch.deletePictureand its exceptions.uploadPictureand its exception.