Skip to content

Commit b218f1f

Browse files
committed
Revert changes to test-utils getClient
1 parent 772761f commit b218f1f

File tree

1 file changed

+26
-13
lines changed

1 file changed

+26
-13
lines changed

tests/utils/meilisearch-test-utils.ts

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,32 @@ async function getKey(permission: string): Promise<string> {
4646
}
4747

4848
async function getClient(permission: string): Promise<MeiliSearch> {
49-
const apiKey =
50-
permission === 'Search' || permission === 'Admin'
51-
? await getKey(permission)
52-
: permission === 'No'
53-
? undefined
54-
: null;
55-
56-
return apiKey === null
57-
? masterClient
58-
: new MeiliSearch({
59-
host: HOST,
60-
apiKey,
61-
});
49+
if (permission === 'No') {
50+
const anonymousClient = new MeiliSearch({
51+
host: HOST,
52+
});
53+
return anonymousClient;
54+
}
55+
56+
if (permission === 'Search') {
57+
const searchKey = await getKey(permission);
58+
const searchClient = new MeiliSearch({
59+
host: HOST,
60+
apiKey: searchKey,
61+
});
62+
return searchClient;
63+
}
64+
65+
if (permission === 'Admin') {
66+
const adminKey = await getKey(permission);
67+
const adminClient = new MeiliSearch({
68+
host: HOST,
69+
apiKey: adminKey,
70+
});
71+
return adminClient;
72+
}
73+
74+
return masterClient;
6275
}
6376

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

0 commit comments

Comments
 (0)