-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into tfk/pub-filter
- Loading branch information
Showing
5 changed files
with
527 additions
and
117 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,48 @@ | ||
import fs from "fs/promises"; | ||
|
||
import { beforeAll, describe, expect, it } from "vitest"; | ||
|
||
import { mockServerCode } from "~/lib/__tests__/utils"; | ||
import { env } from "../env/env.mjs"; | ||
|
||
const { createForEachMockedTransaction } = await mockServerCode(); | ||
|
||
const { getTrx } = createForEachMockedTransaction(); | ||
|
||
beforeAll(async () => { | ||
// check if minio is up | ||
|
||
if (!env.ASSETS_STORAGE_ENDPOINT) { | ||
throw new Error( | ||
"You should only run this test against a local minio instance, not to prod S3" | ||
); | ||
} | ||
|
||
const check = await fetch(env.ASSETS_STORAGE_ENDPOINT, { | ||
method: "OPTIONS", | ||
}); | ||
|
||
if (!check.ok) { | ||
throw new Error( | ||
"Minio is not running. Please setup the test environment properly by running `pnpm -w test:setup`" | ||
); | ||
} | ||
}); | ||
|
||
describe("assets upload", () => { | ||
it("should be able to upload a file to the minio bucket from the server", async () => { | ||
const { uploadFileToS3 } = await import("./assets"); | ||
|
||
const file = await fs.readFile(new URL("./assets.ts", import.meta.url)); | ||
|
||
const url = await uploadFileToS3("test", "test.ts", file, { | ||
contentType: "text/plain", | ||
}); | ||
|
||
expect(url).toBeDefined(); | ||
|
||
const text = await fetch(url).then((res) => res.text()); | ||
|
||
expect(text).toEqual(file.toString("utf8")); | ||
}); | ||
}); |
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
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
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
Oops, something went wrong.