Skip to content

Commit

Permalink
Merge pull request #175 from eexit/add_integration_testing
Browse files Browse the repository at this point in the history
Add manual integration testing
  • Loading branch information
eexit authored Dec 6, 2023
2 parents 0f0161c + da12fec commit 60a9ab6
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 3 deletions.
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

0 comments on commit 60a9ab6

Please sign in to comment.