-
Notifications
You must be signed in to change notification settings - Fork 11
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
Implement KeyValueAccessObject API #3
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'use strict'; | ||
|
||
var msgpack = require('msgpack5'); | ||
|
||
module.exports = function createPacker() { | ||
var packer = msgpack({forceFloat64: true}); | ||
packer.register(1, Date, encodeDate, decodeDate); | ||
return packer; | ||
}; | ||
|
||
function encodeDate(obj) { | ||
return new Buffer(obj.toISOString(), 'utf8'); | ||
} | ||
|
||
function decodeDate(buf) { | ||
return new Date(buf.toString('utf8')); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
'use strict'; | ||
|
||
var createDataSource = require('../helpers/data-source-factory'); | ||
var expect = require('../helpers/expect'); | ||
|
||
describe('Juggler API', function() { | ||
require('loopback-datasource-juggler/test/kvao.suite.js')(createDataSource); | ||
}); |
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,26 @@ | ||
'use strict'; | ||
|
||
var composeKey = require('../..')._Connector._composeKey; | ||
var expect = require('../helpers/expect'); | ||
|
||
describe('RedisKeyValueConnector._composeKey', function() { | ||
it('honours the key', function() { | ||
var key1 = composeKey('Car', 'vin'); | ||
var key2 = composeKey('Car', 'name'); | ||
expect(key1).to.not.equal(key2); | ||
}); | ||
|
||
it('honours the model name', function() { | ||
var key1 = composeKey('Product', 'name'); | ||
var key2 = composeKey('Category', 'name'); | ||
expect(key1).to.not.equal(key2); | ||
}); | ||
|
||
it('encodes values', function() { | ||
// This test is based on the knowledge that we are using ':' separator | ||
// when building the composed string | ||
var key1 = composeKey('a', 'b:c'); | ||
var key2 = composeKey('a:b', 'c'); | ||
expect(key1).to.not.equal(key2); | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I suspect this breaks the build-framework test runner. Can this not be run with a single
mocha
command?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.
Well, when running the tests locally, I prefer to run fast unit-tests first before the slower integration tests.
Is there any reasonable way how to use different test command for dev vs. CI while supporting Windows too?
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.
By listing them as
mocha test/unit/*.js test/integration/*.js
won't it test in that order? You could add--bail
to get fail-fast, as well.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.
I believe we should get the same effect by running
mocha test/unit/*.js test/integration.js
. However,--bail
wouldn't have the same effect as it would only show a single error (the first one it fails on -- the current behaviour is it shows all failing unit tests or all integration tests together).That said, I'm OK with
--bail
too as we should be fixing all failing tests anyways so whether we display them altogether at once or one by one via bail doesn't matter to me.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.
Interesting, it seems that this approach works. I'll use it then!
I prefer to see all test failures, it usually helps to understand whether it's a problem in the code (a single test failing) or perhaps something else (many tests failing because of CI environment problem).