Skip to content
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

Add manual integration testing #175

Merged
merged 1 commit into from
Dec 6, 2023
Merged
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
48 changes: 48 additions & 0 deletions Dockerfile.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
FROM ghost:5-alpine as cloudinary
RUN apk add g++ make python3
COPY --chown=node:node . /tmp/ghost-storage-cloudinary
RUN su-exec node yarn add file:/tmp/ghost-storage-cloudinary

FROM ghost:5-alpine
COPY --chown=node:node --from=cloudinary $GHOST_INSTALL/node_modules $GHOST_INSTALL/node_modules
COPY --chown=node:node --from=cloudinary $GHOST_INSTALL/node_modules/ghost-storage-cloudinary $GHOST_INSTALL/content/adapters/storage/ghost-storage-cloudinary
ENV DEBUG="ghost:*,ghost-config,ghost-storage-cloudinary:*"
ARG CLOUDINARY_URL
ENV CLOUDINARY_URL=${CLOUDINARY_URL}
ENV NODE_ENV=development
COPY <<EOF /var/lib/ghost/config.development.json
{
"url": "http://localhost:2368",
"database": {"client": "sqlite3"},
"logging": {
"level": "debug",
"transports": ["stdout"]
},
"server": {"host": "0.0.0.0"},
"paths": {"contentPath": "/var/lib/ghost/content/"},
"imageOptimization": {"resize": false},
"storage": {
"active": "ghost-storage-cloudinary",
"ghost-storage-cloudinary": {
"upload": {
"use_filename": true,
"unique_filename": false,
"overwrite": false,
"folder": "test",
"tags": ["test"]
},
"fetch": {
"transformation": "blog",
"secure": false,
"cdn_subdomain": true
},
"plugins": {
"retinajs": {
"fireForget": true,
"baseWidth": 500
}
}
}
}
}
EOF
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,19 @@ To enable debug logs, set the following environment variable:

DEBUG=ghost-storage-cloudinary:*

Integration testing:

```bash
docker build \
--build-arg CLOUDINARY_URL=cloudinary://.... \
--file Dockerfile.test \
--tag test \
.
docker run -itp 2368:2368 test
```

Go to <http://localhost:2368>.

---

Many thanks to @[mmornati](https://github.com/mmornati), @[sethbrasile](https://github.com/sethbrasile) and all other contributors for their work. In the continuation of this project, don't hesitate to fork, contribute and add more features.
7 changes: 4 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,17 @@ class CloudinaryAdapter extends StorageBase {

return new Promise((resolve, reject) => cloudinary.uploader.upload(imagePath, options.upload, (err, res) => {
if (err) {
debug('uploader:error', err);
debug('cloudinary.uploader:error', err);

return reject(new errors.CloudinaryAdapterError({
err: err,
message: `Could not upload image ${imagePath}`
}));
}
if (url) {
debug('uploader:url', url);

debug('cloudinary.uploader:res', res);

if (url) {
return resolve(cloudinary.url(res.public_id.concat('.', res.format), options.fetch));
}
return resolve();
Expand Down