Skip to content

Refactored test suite to make sure the tests are running isolated #19

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
540535a
base TestCase class and let all test classes should extend the abstra…
ppshobi Apr 20, 2020
fb0ff49
move deleteAllIndexes method inside the client class and get rid of u…
ppshobi Apr 20, 2020
0c5d530
Refactored ClientTest suite
ppshobi Apr 20, 2020
b62febd
Documents Test Refactored
ppshobi Apr 21, 2020
3cb359d
Documents test cleanup and added one more test to ensure single docum…
ppshobi Apr 21, 2020
5f9fc8b
lint
ppshobi Apr 21, 2020
01f3745
Refactored and isolated tests inside Index Test suite
ppshobi Apr 21, 2020
30fca02
Refactored and isolated tests inside Keys and Permissions Test suite
ppshobi Apr 21, 2020
992eeaa
Refactored and isolated tests inside Search Test suite
ppshobi Apr 21, 2020
5433006
Refactored and isolated tests inside Updates Test suite
ppshobi Apr 21, 2020
afcee22
Refactor Test class
ppshobi Apr 21, 2020
73859ec
Refactor displayed attributes test
ppshobi Apr 21, 2020
cb920ee
lint
ppshobi Apr 21, 2020
2d298e5
Merge branch 'master' into setup-base-test-cases-and-refactorings-to-…
ppshobi Apr 21, 2020
cfe6c71
fix the reset dislayed attributes test
ppshobi Apr 22, 2020
59aea52
refactor and isolate distinct attribute test
ppshobi Apr 22, 2020
5e72700
refactor and isolate Ranking Rules test
ppshobi Apr 22, 2020
5da712b
refactor and isolate searchable attributes test
ppshobi Apr 22, 2020
c8bb690
refactor and isolate Settings Test
ppshobi Apr 22, 2020
28a5069
refactor and isolate StopWords Test
ppshobi Apr 22, 2020
a0d8d9e
refactor and isolate Synonyms Test
ppshobi Apr 22, 2020
e703700
lint
ppshobi Apr 22, 2020
7743234
variable name changes
ppshobi Apr 22, 2020
e86a1f1
pull constructor and client creation upto the base class
ppshobi Apr 22, 2020
edd3ea0
extract promise assertion helper to base test case
ppshobi Apr 22, 2020
08a4ebd
extract host and master-key to constants
ppshobi Apr 22, 2020
d0679bd
Merge branch 'master' into setup-base-test-cases-and-refactorings-to-…
ppshobi Apr 22, 2020
47e605c
clean up and make use of the underlying assertValidPromise method
ppshobi Apr 22, 2020
afc9639
namespace tests
ppshobi Apr 22, 2020
474b842
Add script for tests to increase FDs limit
curquiza Apr 24, 2020
f433182
Merge pull request #1 from meilisearch/tests-script
ppshobi Apr 24, 2020
67adb2f
test deleteAllIndexes Method
ppshobi Apr 24, 2020
8e3de7e
Update scripts/tests.sh
ppshobi Apr 24, 2020
b0b8eec
method to flatten options array, so the the request URI produced is i…
ppshobi Apr 28, 2020
96c6c2c
tests to check array based options, string based options and star(wil…
ppshobi Apr 28, 2020
88481c9
Merge remote-tracking branch 'upstream/master' into setup-base-test-c…
ppshobi Apr 29, 2020
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
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
run: docker run -d -p 7700:7700 getmeili/meilisearch:latest ./meilisearch --master-key=masterKey --no-analytics=true

- name: Run test suite
run: vendor/bin/phpunit --color tests/
run: sh scripts/tests.sh

- name: Run linter
run: vendor/bin/php-cs-fixer fix -v --config=.php_cs.dist --using-cache=no --dry-run
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ Each PR should pass the tests and the linter to be accepted.
```bash
# Tests
$ docker run -d -p 7700:7700 getmeili/meilisearch:latest ./meilisearch --master-key=masterKey --no-analytics=true
$ vendor/bin/phpunit --color tests/
$ sh scripts/tests.sh
# Linter (with auto-fix)
$ vendor/bin/php-cs-fixer fix --verbose --config=.php_cs.dist
# Linter (without auto-fix)
Expand Down
5 changes: 1 addition & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
},
"files": [
"tests/utils.php"
]
}
},
"require-dev": {
"phpunit/phpunit": "^8.5",
Expand Down
7 changes: 7 additions & 0 deletions scripts/tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

echo 'Setting FDs limit to 1000'
ulimit -Sn 1000

echo "Launching tests..."
vendor/bin/phpunit --color tests/
7 changes: 7 additions & 0 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ public function deleteIndex($uid)
return $this->indexInstance($uid)->delete();
}

public function deleteAllIndexes()
{
foreach ($this->getAllIndexes() as $index) {
$this->deleteIndex($index['uid']);
}
}

public function getIndex($uid)
{
return $this->indexInstance($uid);
Expand Down
20 changes: 16 additions & 4 deletions src/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,14 @@ public function waitForPendingUpdate($update_id, $timeout_in_ms = 5000, $interva

public function search($query, $options = null)
{
if (isset($options)) {
$paramters = array_merge(['q' => $query], $options);
if ($options) {
$options = $this->flattenOptions($options);
$parameters = array_merge(['q' => $query], $options);
} else {
$paramters = ['q' => $query];
$parameters = ['q' => $query];
}

return $this->httpGet('/indexes/'.$this->uid.'/search', $paramters);
return $this->httpGet('/indexes/'.$this->uid.'/search', $parameters);
}

// Stats
Expand Down Expand Up @@ -255,4 +256,15 @@ public function updateAcceptNewFields($accept_new_fields)
{
return $this->httpPost('/indexes/'.$this->uid.'/settings/accept-new-fields', $accept_new_fields);
}

private function flattenOptions(array $options)
{
return array_map(function ($entry) {
if (is_array($entry)) {
return implode(',', $entry);
}

return $entry;
}, $options);
}
}
166 changes: 0 additions & 166 deletions tests/ClientTest.php

This file was deleted.

Loading