Skip to content

Commit

Permalink
feat: add clean up discord message method for REST test (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
EiffelFly authored Mar 16, 2023
1 parent a9e5698 commit 2fe54bb
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .changeset/tender-toys-warn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"curioucity": minor
---

Add clean up discord message method for REST test
29 changes: 15 additions & 14 deletions tests/api/rest.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,21 @@ export const options = {};
export const API_HOST = "http://localhost:8080";

const main = () => {
urlServices.createUrl();
urlServices.deleteUrl();
urlServices.getUrl();
urlServices.listUrl();
urlServices.cleanUpUrl();
tagServices.createTag();
tagServices.deleteTag();
tagServices.getTag();
tagServices.listTag();
tagServices.cleanUpTag();
// discordServices.createDiscordMessage();
// discordServices.deleteDiscordMessage();
// discordServices.getDiscordMessage();
// discordServices.listDiscordMessage();
// urlServices.createUrl();
// urlServices.deleteUrl();
// urlServices.getUrl();
// urlServices.listUrl();
// urlServices.cleanUpUrl();
// tagServices.createTag();
// tagServices.deleteTag();
// tagServices.getTag();
// tagServices.listTag();
// tagServices.cleanUpTag();
discordMessageServices.createDiscordMessage();
discordMessageServices.deleteDiscordMessage();
discordMessageServices.getDiscordMessage();
discordMessageServices.listDiscordMessage();
discordMessageServices.cleanUpDiscordMessage();
// discordServices.createDiscordThread();
// discordServices.deleteDiscordThread();
// discordServices.getDiscordThread();
Expand Down
40 changes: 40 additions & 0 deletions tests/api/rest_discord_message.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,3 +329,43 @@ export const listDiscordMessage = () => {
}
});
};

export const cleanUpDiscordMessage = () => {
const listDiscordMessageResponse = http.request(
"GET",
`${API_HOST}/discord/messages`,
undefined,
{
headers: {
"Content-Type": "application/json",
},
}
);

if (
listDiscordMessageResponse.status === 200 &&
listDiscordMessageResponse.json() &&
listDiscordMessageResponse.json().discord_messages &&
listDiscordMessageResponse.json().discord_messages.length > 0
) {
for (const discordMessage of listDiscordMessageResponse.json()
.discord_messages) {
check(
http.request(
"DELETE",
`${API_HOST}/discord/messages/${discordMessage.message_id}`,
undefined,
{
headers: {
"Content-Type": "application/json",
},
}
),
{
"cleanUpDiscordMessage - DELETE /discord/messages/:message_id - response status should be 204":
(r) => r.status === 204,
}
);
}
}
};

0 comments on commit 2fe54bb

Please sign in to comment.