Skip to content

Commit f2a6691

Browse files
committed
issue #6 - add integration-test workflow + readme - DRAFT
1 parent 1ffb277 commit f2a6691

File tree

2 files changed

+106
-0
lines changed

2 files changed

+106
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Integration Tests
2+
3+
on:
4+
pull_request:
5+
workflow_dispatch: # allow manual trigger
6+
7+
jobs:
8+
test-action:
9+
runs-on: ubuntu-latest
10+
11+
services:
12+
mongodb:
13+
image: mongo
14+
ports:
15+
- 27017:27017
16+
17+
steps:
18+
- uses: actions/checkout@v3
19+
20+
# Test local action
21+
- name: Test local action
22+
uses: ./
23+
24+
- name: Verify installation
25+
run: |
26+
# mongo-tools
27+
mongodump --version
28+
mongorestore --version
29+
30+
# mongo-shell
31+
mongosh --version
32+
33+
- name: Functional test
34+
run: |
35+
# Create test user
36+
mongosh admin --eval 'db.createUser({user:"testuser",pwd:"testpass",roles:[{role:"readWrite",db:"testdb"}]});'
37+
38+
# Create testdb with testcollection and one doc
39+
mongosh testdb --eval 'db.testcollection.insert({test: "data"});'
40+
41+
# dump
42+
mongodump --db testdb --out ./dump
43+
44+
# check dump exists
45+
if [ ! -d "./dump/testdb" ]; then
46+
echo "Dump failed"
47+
exit 1
48+
fi
49+
50+
# Drop db
51+
mongosh testdb --eval 'db.dropDatabase();'
52+
53+
# Restore it
54+
mongorestore ./dump
55+
56+
# check restored data
57+
COUNT=$(mongosh testdb --quiet --eval 'db.testcollection.count()')
58+
if [ "$COUNT" != "1" ]; then
59+
echo "Restore verification failed"
60+
exit 1
61+
fi

TESTING.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Testing the Action
2+
3+
This document describes how to test the action both locally and through GitHub.
4+
5+
## Local Testing
6+
7+
To test the action locally, you'll need:
8+
9+
- [Act](https://github.com/nektos/act) - A tool for running GitHub Actions locally
10+
- Docker installed on your machine
11+
12+
### Installation
13+
14+
- Install Act following the instructions at https://github.com/nektos/act#installation
15+
16+
### Running Tests
17+
18+
- From the root of the repository, run:
19+
```bash
20+
act pull_request
21+
```
22+
23+
This will execute the integration test workflow locally using Act.
24+
25+
## GitHub Testing
26+
27+
The integration tests will automatically run on:
28+
- Every Pull Request
29+
- Manual trigger through the GitHub Actions interface
30+
31+
The workflow will:
32+
1. Install the action from the local repository
33+
2. Verify that all MongoDB tools are correctly installed
34+
3. Perform a functional test including:
35+
- Creating a test user
36+
- Creating test data
37+
- Testing mongodump
38+
- Testing mongorestore
39+
- Verifying data integrity
40+
41+
## Notes
42+
43+
- The local tests using Act might behave slightly differently from GitHub Actions due to environment differences
44+
- Make sure you have enough disk space for Docker images when testing locally
45+
- The integration tests require Docker to be running locally

0 commit comments

Comments
 (0)