-
Notifications
You must be signed in to change notification settings - Fork 21
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
1.x fix/upsert #129
1.x fix/upsert #129
Conversation
@slnode test please |
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.
More comments to improve the code; also it needs squash as well.
test/cloudant.test.js
Outdated
afterEach(function(done) { | ||
Product.destroyById(1, function(err) { | ||
if (err) return done(err); | ||
done(); |
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.
Instead of:
function(err) {
if (err) return done(err);
done();
}
Just the following line is enough:
done(err)
test/cloudant.test.js
Outdated
if (err) return done(err); | ||
res.id.should.equal('1'); | ||
res.name.should.equal('bread'); | ||
// scenario: upsert does a update |
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.
an update
test/cloudant.test.js
Outdated
Product.upsert({ | ||
id: '1', | ||
name: 'newBread', | ||
}, function(err, res) { |
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 check err
here as well.
test/cloudant.test.js
Outdated
}); | ||
}); | ||
|
||
it('can call upsert with an id and have it create a document without error', |
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.
Probably the following is what you are achieving here:
can call upsert with a primary key and create/update a document without error
Also it is always a good idea if you try primary keys which are not id
as well.
related to #111