Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 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 @@ -72,7 +72,7 @@
return _awsClient;
};

const baseURL = `${options.endpoint.replace(/\/$/, "")}/${options.bucket || ""}`;

Check failure on line 75 in src/drivers/s3.ts

View workflow job for this annotation

GitHub Actions / ci

test/drivers/s3.test.ts

TypeError: Cannot read properties of undefined (reading 'replace') ❯ src/drivers/s3.ts:75:39 ❯ test/drivers/s3.test.ts:15:18

const url = (key: string = "") => `${baseURL}/${normalizeKey(key, "/")}`;

Expand Down Expand Up @@ -162,6 +162,7 @@
return {
name: DRIVER_NAME,
options,
getInstance: getAwsClient,
getItem(key) {
return getObject(key).then((res) => (res ? res.text() : null));
},
Expand Down
21 changes: 13 additions & 8 deletions test/drivers/s3.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ 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 +41,10 @@ describe.skipIf(
expect(response.status).toBe(200);
expect(await response.text()).toBe("ok");
});

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