Skip to content

Conversation

ptrblgh
Copy link
Contributor

@ptrblgh ptrblgh commented May 6, 2017

Related to #247 .

@slnode
Copy link

slnode commented May 6, 2017

Can one of the admins verify this patch? To accept patch and trigger a build add comment ".ok\W+to\W+test."

@slnode
Copy link

slnode commented May 6, 2017

Can one of the admins verify this patch?

2 similar comments
@slnode
Copy link

slnode commented May 6, 2017

Can one of the admins verify this patch?

@slnode
Copy link

slnode commented May 6, 2017

Can one of the admins verify this patch?

@ssh24
Copy link
Contributor

ssh24 commented May 7, 2017

@ptrblgh Thank you for the contribution. Could you also add some unit tests to prevent future regression?

Also please sign the Contributor License Agreement before we can proceed with the PR.

@ssh24
Copy link
Contributor

ssh24 commented May 9, 2017

@ptrblgh Any updates on adding some test cases with this patch?

@ptrblgh
Copy link
Contributor Author

ptrblgh commented May 9, 2017

Not yet, I'm stuck right now to make the test fail but working on it.

@ssh24
Copy link
Contributor

ssh24 commented May 9, 2017

Not sure what you mean. Are you having difficulties writing the test case?

Here is a quick example of one case:

 postgresDs.automigrate(function(err, result) { if (err) throw err; Expense.create([ { Description: 'Expense 1', Amount: 12, Stamp: '1999-01-08 12:25:00', }, ], function(err, result) { if (err) throw err; Expense.find({where: {Stamp: {like: '1999%'}}}, function(err, result) { if (err) throw err; console.log('Result: ' + JSON.stringify(result)); }); });

Please note this is just the use case, you need to have asserts to make it a more of a test case. Also please be sure to add test cases where the operation is of type ilike, nlike, nilike.

@ssh24 ssh24 self-assigned this May 15, 2017
@ssh24
Copy link
Contributor

ssh24 commented May 15, 2017

@ptrblgh Any updates on adding the test cases?

@ptrblgh
Copy link
Contributor Author

ptrblgh commented May 18, 2017

@ssh24 Sorry for the delay. I have added tests for this patch.

@ssh24
Copy link
Contributor

ssh24 commented May 18, 2017

@ptrblgh Thank you. I will be looking into it soon. Could you please rebase your branch and fix your commit linter?

Rules for commit messages:

  • The first line of the commit message should be no longer than 50 characters long
  • The second line should be empty
  • Every subsequent line should be no longer than 72 characters long

You could also give me access to handle the rebase/commit fixing by clicking Allow edit from Maintainers on the right hand side of this page.

@ptrblgh
Copy link
Contributor Author

ptrblgh commented May 18, 2017

No problem, allow granted. 👍

@ssh24 ssh24 force-pushed the explicit-typecast-for-pattern-match branch from 4ec27a6 to e06e1f1 Compare May 21, 2017 01:15
@ssh24
Copy link
Contributor

ssh24 commented May 21, 2017

Thank you. Code rebased.

Also PR looks good to me. Brilliant! 👍

@slnode test please

title: 't2',
content: 'T2_TheOtherCase',
}]);
PostWithDate.create([
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ptrblgh There is an issue here. Since the functions are async, it does not work like that and hence the tests are failing. You need to do something like this:

Post.create([...], function(err, result) { should.not.exist(err); PostWithDate.create([..], done}); 
@ptrblgh
Copy link
Contributor Author

ptrblgh commented May 21, 2017

@ssh24 Thank you for the hint! I have changed the code, but can't leave the PostWithDate definition inside automigrate, because the test will fail with missing postwithdate table relation.

I came up with this solution (tests are OK):

function createTestFixtures(done) { PostWithDate = db.define('PostWithDate', { title: {type: String, length: 255, index: true}, content: {type: String}, created: { type: String, postgresql: { dataType: 'timestamp with time zone' } } }); db.automigrate(function(err, result) { if (err) throw err; Post.create([{ title: 't1', content: 'T1_TestCase', }, { title: 't2', content: 'T2_TheOtherCase', }], function(err, result) { should.not.exist(err); PostWithDate.create([ { title: 'Title 1', content: 'Content 1', created: '2017-05-17 12:00:01' }, { title: 'Title 2', content: 'Content 2', created: '2017-04-17 12:00:01' }, ], done); }); }); }

If this code looks good for you I'll make a commit :).

Other question:
I got 2 other tests failing (not connected to this one):

  1. manipulation updateOrCreate when forceId is true fails when id does not exist in db & validate is false:
    Uncaught TypeError: Cannot read property 'statusCode' of null
  2. manipulation updateOrCreate when forceId is true fails when id does not exist in db & validate is false when using updateAttributes:
    Uncaught TypeError: Cannot read property 'statusCode' of null

Is this only for me? Should I change something in my config to pass these tests too?

Copy link
Contributor

@ssh24 ssh24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ptrblgh That sounds good to me 👍. Also please make the changes I have requested on the deleteTestFixtures function to destroy the data after the test.

Also not sure why some tests are failing on your local. I just did a dry run on my local with the changes and it all passed. The tests that failed are juggler tests. Could you install your dependencies again using npm i? Maybe you are using an older version of juggler/connector.

});

function deleteTestFixtures(done) {
Post.destroyAll(done);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also destroy the data after the test is done here?

 function deleteTestFixtures(done) { Post.destroyAll(function(err) { should.not.exist(err); PostWithDate.destroyAll(done); }); }
@ptrblgh
Copy link
Contributor Author

ptrblgh commented May 28, 2017

@ssh24 missing clean up added to the test case.

@ssh24 ssh24 force-pushed the explicit-typecast-for-pattern-match branch from 2d9073c to 0b9074c Compare May 28, 2017 23:52
@ssh24
Copy link
Contributor

ssh24 commented May 28, 2017

@ptrblgh Thank you. Rebased your branch. Code looks good to me. 👍

@slnode test please

@ssh24 ssh24 merged commit ef64660 into loopbackio:master May 29, 2017
@ssh24 ssh24 added the apex label May 29, 2017
@ssh24 ssh24 added this to the Sprint 36 - Apex milestone May 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants