generated from nhcarrigan/template
test: assert all cdn files are included in app (#50)
### Explanation _No response_ ### Issue _No response_ ### Attestations - [ ] I have read and agree to the [Code of Conduct](https://docs.nhcarrigan.com/community/coc/) - [ ] I have read and agree to the [Community Guidelines](https://docs.nhcarrigan.com/community/guide/). - [ ] My contribution complies with the [Contributor Covenant](https://docs.nhcarrigan.com/dev/covenant/). ### Dependencies - [ ] I have pinned the dependencies to a specific patch version. ### Style - [ ] I have run the linter and resolved any errors. - [ ] My pull request uses an appropriate title, matching the conventional commit standards. - [ ] My scope of feat/fix/chore/etc. correctly matches the nature of changes in my pull request. ### Tests - [ ] My contribution adds new code, and I have added tests to cover it. - [ ] My contribution modifies existing code, and I have updated the tests to reflect these changes. - [ ] All new and existing tests pass locally with my changes. - [ ] Code coverage remains at or above the configured threshold. ### Documentation _No response_ ### Versioning _No response_ Reviewed-on: https://codeberg.org/nhcarrigan/portfolio/pulls/50 Co-authored-by: Naomi Carrigan <commits@nhcarrigan.com> Co-committed-by: Naomi Carrigan <commits@nhcarrigan.com>
This commit is contained in:
parent
203ae63c78
commit
ea0392b3f7
@ -8,7 +8,7 @@
|
|||||||
"build": "next build",
|
"build": "next build",
|
||||||
"start": "next start",
|
"start": "next start",
|
||||||
"lint": "eslint src test --max-warnings 0",
|
"lint": "eslint src test --max-warnings 0",
|
||||||
"test": "vitest run --coverage",
|
"test": "op run --env-file=do.env --no-masking -- vitest run --coverage",
|
||||||
"koikatsu": "op run --env-file=do.env --no-masking -- tsx koikatsu.ts"
|
"koikatsu": "op run --env-file=do.env --no-masking -- tsx koikatsu.ts"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
105
test/cdn.spec.ts
Normal file
105
test/cdn.spec.ts
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
/**
|
||||||
|
* @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: {
|
||||||
|
accessKeyId: process.env.DO_ACCESS_KEY as string,
|
||||||
|
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();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user