-
Notifications
You must be signed in to change notification settings - Fork 54
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
Fix: Deployed by filter capitalization #479
Fix: Deployed by filter capitalization #479
Conversation
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.
Great Work! Just a few comments, also do you mind adding an integration test that executes the same behaviour as described in the bug report?
*/ | ||
|
||
export async function up(pgm: MigrationBuilder): Promise<void> { | ||
pgm.sql(`CREATE INDEX deployer_address_lower_case on deployments (LOWER(deployer_address) text_pattern_ops);`) |
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.
Should we delete the original index on deployer_address
?
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.
Done
when(db.map(anything(), anything(), anything())).thenReturn(Promise.resolve(dbResult)) | ||
}) | ||
|
||
it('should return a map of entity id to the deployment status', async () => { |
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 update this text to reflect what you are verifying
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 is the correct verification, splitted the test for two different verifications
const entities = ['1', '3'] | ||
const result = await repository.areEntitiesDeployed(entities) | ||
|
||
expect(result).toEqual( |
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'd remove this as the only thing that you are testing is the mock
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 is asserting on the logic of the map creation in the return statement of the function
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.
My bad!
}) | ||
}) | ||
|
||
describe('when the entities list is empty', () => { |
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 test doesn't seem to add value as you are only testing the mock.
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 is asserting on the first if of the function (
if (entityIds.length === 0) { |
never called
of the mock
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.
My bad!
const args = capture(db.map).last() | ||
|
||
expect(args[0]).toContain(`ORDER BY dep1.entity_timestamp ASC`) | ||
expect(args[0]).toContain( |
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.
niceeeeee 👏
describe('when it receives a lastId', () => { | ||
const lastId = '1' | ||
|
||
beforeEach(() => { |
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.
As we don't really care about the response from the MockedDataBase can we configure this only once for the entire file?
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 can, but that makes the tests coupled since the mock is the same among all tests
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.
That's why I initialized it in each test context
}) | ||
|
||
it('should add the expected where clause to the query with the addresses on lowercase', async () => { | ||
const deployedBy = ['jOn', 'aGus'] |
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.
🤣
const args = capture(db.map).last() | ||
|
||
expect(args[0]).toContain(`LOWER(dep1.deployer_address) IN ($(deployedBy:list))`) | ||
expect(args[1]).toEqual(jasmine.objectContaining({ deployedBy: deployedBy.map((x) => x.toLowerCase()) })) |
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.
nit: as this is the expected param, shouldn't it be hardcoded?
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.
Updated to have it hardcoded
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.
Great work, especially creating the repository tests! 👏
Just check the two comments and then you are free to merge.
} | ||
|
||
export async function down(pgm: MigrationBuilder): Promise<void> { | ||
pgm.sql(`DROP INDEX deployer_address_lower_case;`) |
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.
If we are maintaining those down functions then we should create the original index here
This PR:
createOrClause
method where the timestamp type was hardcoded and didn't change based on the filter typeFixes #291