From 244f8a884f072bab0f28376f4f7dbbc1f7a8f875 Mon Sep 17 00:00:00 2001 From: Erik Huelsmann Date: Thu, 2 Jan 2025 15:12:32 +0100 Subject: [PATCH] Add Makefile command to quickly create a test company --- Makefile | 9 +++++++++ utils/devel/create-test-db | 11 +++++++++++ 2 files changed, 20 insertions(+) create mode 100755 utils/devel/create-test-db diff --git a/Makefile b/Makefile index b3bcd48e9a..752157f05d 100644 --- a/Makefile +++ b/Makefile @@ -56,6 +56,9 @@ Help on using this Makefile - serve : Runs the 'webpack serve' command - devtest : Runs all tests including development tests (TESTS='t/ xt/') - jstest : Runs all UI tests (TESTS='UI/tests') + - testdb : Creates test database (TESTDB='test') + with user (TESTUSER='test') + and config (TESTCONF='locale/coa/us/General.xml') - pherkin : Runs all BDD tests with 'pherkin' (instead of 'prove') - blacklist : Builds sql blacklist (required after adding functions) @@ -155,6 +158,12 @@ test: TESTS ?= t/ test: $(DOCKER_CMD) yath test --no-color $(TEST_OPTS) $(TESTS) +testdb: TESTDB ?= test +testdb: TESTUSER ?= test +testdb: TESTCONF ?= locale/coa/us/General.xml +testdb: + $(DOCKER_CMD) bash -c "TESTUSER='$(TESTUSER)' utils/devel/create-test-db '${TESTDB}' '${TESTCONF}'" + devtest: TESTS ?= t/ xt/ devtest: PGTAP_OPTS ?= --pgtap-dbname=lsmb_test --pgtap-username=postgres \ --pgtap-psql=.circleci/psql-wrap diff --git a/utils/devel/create-test-db b/utils/devel/create-test-db new file mode 100755 index 0000000000..8bf9104a8c --- /dev/null +++ b/utils/devel/create-test-db @@ -0,0 +1,11 @@ +#!/bin/bash + +TESTDB=$1 +TESTCONFIG=$2 + +set -x + +bin/ledgersmb-admin create postgres@${POSTGRES_HOST}/${TESTDB}#xyz +bin/ledgersmb-admin setup load postgres@${POSTGRES_HOST}/${TESTDB}#xyz $TESTCONFIG +bin/ledgersmb-admin user create postgres@${POSTGRES_HOST}/${TESTDB}#xyz --username ${TESTUSER:-test} --password abc --ssn 1 --country US --first-name T --last-name E --employeenumber 1 --permission "Full Permissions" +