Skip to content

Commit

Permalink
refactor: clarify scope
Browse files Browse the repository at this point in the history
  • Loading branch information
zyoshoka committed Oct 12, 2024
1 parent 503477f commit 23e7bc7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/backend/test-federation/test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

export const ADMIN_PARAMS = { username: 'admin', password: 'admin' };
const adminCache = new Map<Host, SigninResponse>();
const ADMIN_CACHE = new Map<Host, SigninResponse>();

await Promise.all([
fetchAdmin('a.test'),
Expand Down Expand Up @@ -58,7 +58,7 @@ async function createAdmin(host: Host): Promise<Misskey.entities.SignupResponse
const client = new Misskey.api.APIClient({ origin: `https://${host}` });
return await client.request('admin/accounts/create', ADMIN_PARAMS).then(res => {
console.log(`Successfully created admin account: @${ADMIN_PARAMS.username}@${host}`);
adminCache.set(host, {
ADMIN_CACHE.set(host, {
id: res.id,
// @ts-expect-error FIXME: openapi-typescript generates incorrect response type for this endpoint, so ignore this
i: res.token,
Expand All @@ -82,9 +82,9 @@ async function createAdmin(host: Host): Promise<Misskey.entities.SignupResponse
}

export async function fetchAdmin(host: Host): Promise<LoginUser> {
const admin = adminCache.get(host) ?? await signin(host, ADMIN_PARAMS)
const admin = ADMIN_CACHE.get(host) ?? await signin(host, ADMIN_PARAMS)
.then(res => {
adminCache.set(host, res);
ADMIN_CACHE.set(host, res);
return res;
})
.catch(async err => {
Expand Down

0 comments on commit 23e7bc7

Please sign in to comment.