30 lines
1.2 KiB
Bash
30 lines
1.2 KiB
Bash
|
#!/usr/bin/env bash
|
||
|
|
||
|
########## IMPORT EXPORT/SCRIPT FOR DREDD TEST DATA ############
|
||
|
###----------------------------------------------------------###
|
||
|
###------------------ HOW TO USE THIS FILE ------------------###
|
||
|
###----------------------------------------------------------###
|
||
|
### 1. start express server with `npm run start-test` ###
|
||
|
### 2. import data by executing script: `./populate-data.sh` ###
|
||
|
### 3. change data in app as you need for tests ###
|
||
|
### 4. export data state with: `./populate-data.sh save` ###
|
||
|
################################################################
|
||
|
|
||
|
# execute script in its location folder
|
||
|
cd $(dirname $0)
|
||
|
|
||
|
# array of available collection names
|
||
|
col=(app_user awarding campaign decoration logBudget logFlag logKill logPoints logRespawn logRevive logTransport player promotion rank squad user war )
|
||
|
|
||
|
for i in "${col[@]}"
|
||
|
do
|
||
|
# provide date for restore process, if data import is needed
|
||
|
if [ "$1" == "save" ]
|
||
|
then
|
||
|
echo -e "$(date "+%Y-%m-%dT%T.%3N%z")\tTable: ${i}"
|
||
|
mongoexport --db cc-test --collection $i --out data/${i}.json;
|
||
|
else
|
||
|
mongoimport --db cc-test --collection $i --drop --file data/${i}.json
|
||
|
fi
|
||
|
done
|