Skip to content

Commit

Permalink
Revert changes to test-utils getClient
Browse files Browse the repository at this point in the history
  • Loading branch information
flevi29 committed Aug 22, 2024
1 parent 772761f commit b218f1f
Showing 1 changed file with 26 additions and 13 deletions.
39 changes: 26 additions & 13 deletions tests/utils/meilisearch-test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,32 @@ async function getKey(permission: string): Promise<string> {
}

async function getClient(permission: string): Promise<MeiliSearch> {
const apiKey =
permission === 'Search' || permission === 'Admin'
? await getKey(permission)
: permission === 'No'
? undefined
: null;

return apiKey === null
? masterClient
: new MeiliSearch({
host: HOST,
apiKey,
});
if (permission === 'No') {
const anonymousClient = new MeiliSearch({
host: HOST,
});
return anonymousClient;
}

if (permission === 'Search') {
const searchKey = await getKey(permission);
const searchClient = new MeiliSearch({
host: HOST,
apiKey: searchKey,
});
return searchClient;
}

if (permission === 'Admin') {
const adminKey = await getKey(permission);
const adminClient = new MeiliSearch({
host: HOST,
apiKey: adminKey,
});
return adminClient;
}

return masterClient;
}

const clearAllIndexes = async (config: Config): Promise<void> => {
Expand Down

0 comments on commit b218f1f

Please sign in to comment.