-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3ec5118
commit 19d8680
Showing
3 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import type { Status as ApiStatus } from "@versia/client/types"; | ||
import { fakeRequest, getTestStatuses, getTestUsers } from "~/tests/utils"; | ||
import { run, bench } from "mitata"; | ||
import { configureLoggers } from "@/loggers"; | ||
|
||
await configureLoggers(true); | ||
|
||
const { users, tokens, deleteUsers } = await getTestUsers(5); | ||
await getTestStatuses(40, users[0]); | ||
|
||
const testTimeline = async (): Promise<void> => { | ||
const response = await fakeRequest("/api/v1/timelines/home", { | ||
headers: { | ||
Authorization: `Bearer ${tokens[0].data.accessToken}`, | ||
}, | ||
}); | ||
|
||
const objects = (await response.json()) as ApiStatus[]; | ||
|
||
if (objects.length !== 20) { | ||
throw new Error("Invalid response (not 20 objects)"); | ||
} | ||
}; | ||
|
||
const testInstance = async (): Promise<void> => { | ||
const response = await fakeRequest("/api/v2/instance", { | ||
headers: { | ||
Authorization: `Bearer ${tokens[0].data.accessToken}`, | ||
}, | ||
}); | ||
|
||
const object = (await response.json()) as Record<string, unknown>; | ||
|
||
if (typeof object !== "object") { | ||
throw new Error("Invalid response (not an object)"); | ||
} | ||
}; | ||
|
||
bench("timeline", testTimeline).range("amount", 1, 1000); | ||
bench("instance", testInstance).range("amount", 1, 1000); | ||
|
||
await run(); | ||
|
||
await deleteUsers(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters