Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/drivers/s3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ export default defineDriver((options: S3DriverOptions) => {
return {
name: DRIVER_NAME,
options,
getInstance: getAwsClient,
getItem(key) {
return getObject(key).then((res) => (res ? res.text() : null));
},
Expand Down
22 changes: 14 additions & 8 deletions test/drivers/s3.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@ const region = process.env.VITE_S3_REGION;
describe.skipIf(
!accessKeyId || !secretAccessKey || !bucket || !endpoint || !region
)("drivers: s3", () => {
const driver = () =>
s3Driver({
accessKeyId: accessKeyId!,
secretAccessKey: secretAccessKey!,
bucket: bucket!,
endpoint: endpoint!,
region: region!,
});

testDriver({
driver: () =>
s3Driver({
accessKeyId: accessKeyId!,
secretAccessKey: secretAccessKey!,
bucket: bucket!,
endpoint: endpoint!,
region: region!,
}),
driver,
additionalTests(ctx) {
it("can access directly with / separator", async () => {
await ctx.storage.set("foo/bar:baz", "ok");
Expand All @@ -40,6 +42,10 @@ describe.skipIf(
expect(response.status).toBe(200);
expect(await response.text()).toBe("ok");
});

it("exposes instance", () => {
expect(driver().getInstance?.()).toBeInstanceOf(AwsClient);
});
},
});
});