Skip to content

issue #6 - add integration-test workflow + readme #2

issue #6 - add integration-test workflow + readme

issue #6 - add integration-test workflow + readme #2

name: Integration Tests
on:
pull_request:
workflow_dispatch: # allow manual trigger
jobs:
test-action:
runs-on: ubuntu-latest
services:
mongodb:
image: mongo
ports:
- 27017:27017
steps:
- uses: actions/checkout@v3
# Test local action
- name: Test local action
uses: ./
- name: Verify installation
run: |
# mongo-tools
mongodump --version
mongorestore --version
# mongo-shell
mongosh --version
- name: Functional test
run: |
# Create test user
mongosh admin --eval 'db.createUser({user:"testuser",pwd:"testpass",roles:[{role:"readWrite",db:"testdb"}]});'
# Create testdb with testcollection and one doc
mongosh testdb --eval 'db.testcollection.insertOne({test: "data"});'
# dump
mongodump --db testdb --out ./dump
# check dump exists
if [ ! -d "./dump/testdb" ]; then
echo "Dump failed"
exit 1
fi
# Drop db
mongosh testdb --eval 'db.dropDatabase();'
# Restore it
mongorestore ./dump
# check restored data
COUNT=$(mongosh testdb --eval 'db.testcollection.count()')
if [ "$COUNT" != "1" ]; then
echo "Restore verification failed - count:$COUNT"
exit 1
fi