2024-11-27 05:45:08 +00:00
|
|
|
/**
|
|
|
|
* @copyright nhcarrigan
|
|
|
|
* @license Naomi's Public License
|
|
|
|
* @author Naomi Carrigan
|
|
|
|
*/
|
|
|
|
|
|
|
|
import { ListObjectsV2Command, S3Client } from "@aws-sdk/client-s3";
|
|
|
|
import { describe, it, expect } from "vitest";
|
|
|
|
import { Art } from "../src/config/Art";
|
|
|
|
import { Certifications } from "../src/config/Certifications";
|
|
|
|
import { Games } from "../src/config/Games";
|
|
|
|
import { Koikatsu } from "../src/config/Koikatsu";
|
|
|
|
|
|
|
|
const s3 = new S3Client({
|
|
|
|
credentials: {
|
2024-11-27 06:01:37 +00:00
|
|
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
2024-11-27 05:45:08 +00:00
|
|
|
accessKeyId: process.env.DO_ACCESS_KEY as string,
|
2024-11-27 06:01:37 +00:00
|
|
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
2024-11-27 05:45:08 +00:00
|
|
|
secretAccessKey: process.env.DO_SECRET_KEY as string,
|
|
|
|
},
|
|
|
|
endpoint: "https://sfo3.digitaloceanspaces.com",
|
|
|
|
region: "sfo3",
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("cdn files", () => {
|
|
|
|
describe("for games", async() => {
|
|
|
|
const command = new ListObjectsV2Command({
|
|
|
|
Bucket: "nhcarrigan-cdn",
|
|
|
|
Prefix: "games",
|
|
|
|
});
|
|
|
|
|
|
|
|
const { Contents } = await s3.send(command);
|
|
|
|
|
|
|
|
const names = Contents?.map((content) => {
|
|
|
|
return content.Key?.replace("games/", "");
|
|
|
|
}).filter(Boolean) || [];
|
|
|
|
|
|
|
|
it.each(names)("should have %s in the Games config", (name) => {
|
|
|
|
expect.assertions(1);
|
|
|
|
const isGameInConfig = Games.some((game) => {
|
|
|
|
return game.img === name;
|
|
|
|
});
|
|
|
|
expect(isGameInConfig, "is not in config").toBeTruthy();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("for koikatsu", async() => {
|
|
|
|
const command = new ListObjectsV2Command({
|
|
|
|
Bucket: "nhcarrigan-cdn",
|
|
|
|
Prefix: "koikatsu",
|
|
|
|
});
|
|
|
|
|
|
|
|
const { Contents } = await s3.send(command);
|
|
|
|
|
|
|
|
const names = Contents?.map((content) => {
|
|
|
|
return content.Key?.replace("koikatsu/", "");
|
|
|
|
}).filter(Boolean) || [];
|
|
|
|
|
|
|
|
it.each(names)("should have %s in the Koikatsu config", (name) => {
|
|
|
|
expect.assertions(1);
|
|
|
|
const isKoikatsuInConfig = Koikatsu.includes(name);
|
|
|
|
expect(isKoikatsuInConfig, "is not in config").toBeTruthy();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("for art", async() => {
|
|
|
|
const command = new ListObjectsV2Command({
|
|
|
|
Bucket: "nhcarrigan-cdn",
|
|
|
|
Prefix: "art",
|
|
|
|
});
|
|
|
|
|
|
|
|
const { Contents } = await s3.send(command);
|
|
|
|
|
|
|
|
const names = Contents?.map((content) => {
|
|
|
|
return content.Key?.replace("art/", "");
|
|
|
|
}).filter(Boolean) || [];
|
|
|
|
|
|
|
|
it.each(names)("should have %s in the Art config", (name) => {
|
|
|
|
expect.assertions(1);
|
|
|
|
const isArtInConfig = Art.some((art) => {
|
|
|
|
return art.img === name;
|
|
|
|
});
|
|
|
|
expect(isArtInConfig, "is not in config").toBeTruthy();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("for certifications", async() => {
|
|
|
|
const command = new ListObjectsV2Command({
|
|
|
|
Bucket: "nhcarrigan-cdn",
|
|
|
|
Prefix: "certifications",
|
|
|
|
});
|
|
|
|
|
|
|
|
const { Contents } = await s3.send(command);
|
|
|
|
|
|
|
|
const names = Contents?.map((content) => {
|
|
|
|
return content.Key?.replace("certifications/", "");
|
|
|
|
}).filter(Boolean) || [];
|
|
|
|
|
|
|
|
it.each(names)("should have %s in the Certifications config", (name) => {
|
|
|
|
expect.assertions(1);
|
|
|
|
const isCertInConfig = Certifications.some((cert) => {
|
|
|
|
return cert.fileName === name;
|
|
|
|
});
|
|
|
|
expect(isCertInConfig, "is not in config").toBeTruthy();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|