-
Notifications
You must be signed in to change notification settings - Fork 17
Optional deps #453
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
KoblerS
wants to merge
9
commits into
main
Choose a base branch
from
optional-deps
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Optional deps #453
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
47d307c
feat: add optional peer dependency checks for AWS, Azure, and GCP sto…
KoblerS 0d7a9e0
feat: make cloud storage SDKs optional peer dependencies with error h…
KoblerS 0dd1dbd
feat: add optional peer dependency checks for AWS, Azure, and GCP sto…
KoblerS 28066a0
feat: make cloud storage SDKs optional peer dependencies with error h…
KoblerS 1b2f1d1
fix: enhance error handling for missing optional dependencies in AWS,…
KoblerS 66a6b04
Merge branch 'optional-deps' of https://github.com/cap-js/attachments…
KoblerS 338b0d3
fix: improve formatting of AWS S3 client import in cleanup function
KoblerS b12e934
Merge branch 'main' into optional-deps
stefanrudi 9f37a3b
chore: adjust error message for missing @aws-sdk/client-s3 in cleanup
stefanrudi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,75 @@ | ||
| describe("optional peer dependency errors", () => { | ||
| const makeNotFound = (pkg) => { | ||
| const err = new Error(`Cannot find module '${pkg}'`) | ||
| err.code = "MODULE_NOT_FOUND" | ||
| return err | ||
| } | ||
|
|
||
| test("aws-s3 throws helpful error when @aws-sdk/client-s3 is missing", () => { | ||
| jest.isolateModules(() => { | ||
| jest.doMock("@aws-sdk/client-s3", () => { | ||
| throw makeNotFound("@aws-sdk/client-s3") | ||
| }) | ||
| expect(() => require("../../srv/attachments/aws-s3")).toThrow( | ||
| "npm install @aws-sdk/client-s3 @aws-sdk/lib-storage", | ||
| ) | ||
| }) | ||
| }) | ||
|
|
||
| test("aws-s3 throws helpful error when @aws-sdk/lib-storage is missing", () => { | ||
| jest.isolateModules(() => { | ||
| jest.doMock("@aws-sdk/lib-storage", () => { | ||
| throw makeNotFound("@aws-sdk/lib-storage") | ||
| }) | ||
| expect(() => require("../../srv/attachments/aws-s3")).toThrow( | ||
| "npm install @aws-sdk/client-s3 @aws-sdk/lib-storage", | ||
| ) | ||
| }) | ||
| }) | ||
|
stefanrudi marked this conversation as resolved.
|
||
|
|
||
| test("azure-blob-storage throws helpful error when @azure/storage-blob is missing", () => { | ||
| jest.isolateModules(() => { | ||
| jest.doMock("@azure/storage-blob", () => { | ||
| throw makeNotFound("@azure/storage-blob") | ||
| }) | ||
| expect(() => require("../../srv/attachments/azure-blob-storage")).toThrow( | ||
| "npm install @azure/storage-blob", | ||
| ) | ||
| }) | ||
| }) | ||
|
stefanrudi marked this conversation as resolved.
|
||
|
|
||
| test("gcp throws helpful error when @google-cloud/storage is missing", () => { | ||
| jest.isolateModules(() => { | ||
| jest.doMock("@google-cloud/storage", () => { | ||
| throw makeNotFound("@google-cloud/storage") | ||
| }) | ||
| expect(() => require("../../srv/attachments/gcp")).toThrow( | ||
| "npm install @google-cloud/storage", | ||
| ) | ||
| }) | ||
| }) | ||
|
|
||
| test("aws-s3 loads successfully when SDKs are present", () => { | ||
| jest.isolateModules(() => { | ||
| jest.dontMock("@aws-sdk/client-s3") | ||
| jest.dontMock("@aws-sdk/lib-storage") | ||
| expect(() => require("../../srv/attachments/aws-s3")).not.toThrow() | ||
| }) | ||
| }) | ||
|
|
||
| test("azure-blob-storage loads successfully when SDK is present", () => { | ||
| jest.isolateModules(() => { | ||
| jest.dontMock("@azure/storage-blob") | ||
| expect(() => | ||
| require("../../srv/attachments/azure-blob-storage"), | ||
| ).not.toThrow() | ||
| }) | ||
| }) | ||
|
|
||
| test("gcp loads successfully when SDK is present", () => { | ||
| jest.isolateModules(() => { | ||
| jest.dontMock("@google-cloud/storage") | ||
| expect(() => require("../../srv/attachments/gcp")).not.toThrow() | ||
| }) | ||
| }) | ||
| }) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.