Skip to content
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

Update dart version and checkout #367

Merged
merged 2 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
strategy:
fail-fast: false
matrix:
version: ['3.0.0']
version: ['latest']
name: integration-tests (dart ${{ matrix.version }})
services:
meilisearch:
Expand Down Expand Up @@ -82,10 +82,10 @@ jobs:
name: check .code-samples.meilisearch.yaml
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: dart-lang/setup-dart@v1
with:
sdk: '3.0.0'
sdk: 'latest'
- name: check if samples changed
run: |
dart pub get
Expand Down
6 changes: 3 additions & 3 deletions bors.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
status = [
'integration-tests (dart 3.0.0)',
'linter-check',
'pana'
'integration-tests (dart latest)',
'linter-check',
'pana'
]
# 1 hour timeout
timeout-sec = 3600
8 changes: 0 additions & 8 deletions test/models/test_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,10 @@ class TestMeiliSearchClient extends MeiliSearchClient {
}

Future<void> disposeUsedResources() async {
final indexesCopy = usedIndexes.toList();
await Future.wait([
_deleteUsedIndexes(),
_deleteUsedKeys(),
]);
if (indexesCopy.isNotEmpty) {
await _deleteTasksForDeletedIndexes(indexesCopy);
}
}

Future<void> _deleteUsedIndexes() async {
Expand All @@ -131,8 +127,4 @@ class TestMeiliSearchClient extends MeiliSearchClient {
),
);
}

Future<void> _deleteTasksForDeletedIndexes(List<String> indexes) async {
Copy link
Member Author

Choose a reason for hiding this comment

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

@ahmednfwela, this code was causing some intermittent trouble in the CI. You can see some examples here:

Although keeping track of used resources is very clever, it isn't worth it for two reasons. First, it is hard to understand where the error comes from (due to the stack trace dart left behind). And second, because you should always clean up the state before you run the tests, not after.

I like this article that highlights why this should be followed as a good practice: https://docs.cypress.io/guides/references/best-practices#Using-after-Or-afterEach-Hooks I've been applying this concept for a long time, and it helps a lot.

await deleteTasks(params: DeleteTasksQuery(indexUids: indexes));
}
}
13 changes: 10 additions & 3 deletions test/swaps_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,28 @@ void main() {
setUpClient();

test('swaps indexes from input', () async {
var books = ['books', 'books_new'];
var movies = ['movies', 'movies_new'];
var books = [randomUid('books'), randomUid('books_new')];
var movies = [randomUid('movies'), randomUid('movies_new')];
var swaps = [SwapIndex(books), SwapIndex(movies)];

// first create the indexes to be swapped
for (var index in books + movies) {
await client.createIndex(index).waitFor(client: client);
}

var response = await client
.swapIndexes(
swaps,
deleteWhenDone: false,
)
.waitFor(
client: client,
throwFailed: false,
throwFailed: true,
);

expect(response.type, 'indexSwap');
expect(response.error, null);
expect(response.status, 'succeeded');
expect(response.details!['swaps'], [
{'indexes': books},
{'indexes': movies}
Expand Down