-
Notifications
You must be signed in to change notification settings - Fork 117
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
Add Reverse ordering support for Task API #816
base: main
Are you sure you want to change the base?
Conversation
Hi @ma1581, thank you for your PR. 🙌 I merged the changes from the Thanks! |
Hi @Strift . thanks for notifying this. Glad to be part of this |
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.
Thanks a lot for your PR!
Next time I would ask you to make one change per PR, it makes it easier to review :)
@BeforeEach | ||
void beforeEach() { | ||
TimeZone.setDefault(TimeZone.getTimeZone("UTC")); | ||
} | ||
|
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.
Why did you need to set this? And if "yes" why not to set this for the whole test suite?
Task[] defaultTaskList = | ||
client.getTasks(new TasksQuery().setAfterEnqueuedAt(currentTime)).getResults(); | ||
Task[] reversedTaskList = | ||
client.getTasks(new TasksQuery().setAfterEnqueuedAt(currentTime).setReverse(true)) | ||
.getResults(); |
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.
Can you map only the task ids here, and then you assert them later, so the test will be less complex to read.
TaskInfo taskA = client.index(indexUid).addDocuments(testData.getRaw()); | ||
TaskInfo taskB = client.index(indexUid).addDocuments(testData.getRaw()); | ||
|
||
client.waitForTask(taskA.getTaskUid()); |
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 you wait for the last task the first one will be finished in any case so you can remove this line.
Arrays.stream(defaultTaskList).map(Task::getUid).collect(Collectors.toList()); | ||
List<Integer> reversedTaskOrder = | ||
Arrays.stream(reversedTaskList).map(Task::getUid).collect(Collectors.toList()); | ||
assertFalse(originalTaskOrder.isEmpty()); |
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 remove one of these assertions.
@@ -202,6 +205,38 @@ public void testClientGetTasksAllQueryParameters() throws Exception { | |||
assertThat(result.getNext(), is(notNullValue())); | |||
assertThat(result.getResults().length, is(notNullValue())); | |||
} | |||
/** Test to check if task list is reversed when enabled */ |
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.
No need to explain what you're testing, this is usually a smell that your test is too complex. Which is not the case :)
Pull Request
Related issue
Fixes #798
What does this PR do?
PR checklist
Please check if your PR fulfills the following requirements:
Thank you so much for contributing to Meilisearch!