Skip to content

Instantly share code, notes, and snippets.

View davidecaruso's full-sized avatar

Davide Caruso davidecaruso

View GitHub Profile
@davidecaruso
davidecaruso / createDatabase.ts
Last active March 26, 2020 18:45
MongoDB Integration Tests
import mongoose from 'mongoose';
const connect = async () => {
await close();
await mongoose.connect(`${process.env.MONGODB_DATABASE}Test`, {
// Mongoose options
});
};
@davidecaruso
davidecaruso / awesomeFeatureTest.ts
Created March 26, 2020 17:31
MongoDB Integration Tests
import chai from 'chai';
import createDatabase from '~/tests/createDatabase';
chai.should();
createDatabase({before, afterEach, after}, () => {
describe('My Awesome Feature', () => {
it('Should be the best in the world', () => {
// tests
});
@davidecaruso
davidecaruso / install-robo3t.sh
Last active October 22, 2021 07:26
Install Robo3T on Linux
#!/bin/bash
cd /tmp || exit
printf "Downloading Robo 3T...\n"
filename="${1:-robo3t-1.4.4-linux-x86_64-e6ac9ec}"; # Default: v1.4.4
wget -q https://download.studio3t.com/robomongo/linux/$filename.tar.gz
if [ $? -ne 0 ];then
printf "Invalid package given.\n"
exit 1
fi
@davidecaruso
davidecaruso / prepare-commit-msg
Last active November 16, 2023 10:58
Git hook to prefix commit with Jira ticket
#!/bin/bash
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
if [ -n "$BRANCH_NAME" ] && [ "$BRANCH_NAME" != "HEAD" ] && [ "$SKIP_PREPARE_COMMIT_MSG" != 1 ]; then
PREFIX_PATTERN='[A-Z]{2,}\-[0-9]{2,}'
[[ $BRANCH_NAME =~ $PREFIX_PATTERN ]]
PREFIX=${BASH_REMATCH[0]}
PREFIX_IN_COMMIT=$(grep -c "^$PREFIX\:" "$1")
if [[ -n "$PREFIX" ]] && ! [[ $PREFIX_IN_COMMIT -ge 1 ]]; then