Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions .github/workflows/tests_mergin_db_sync.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Tests for Mergin DB Sync

on:
push:
paths:
- "test/**"
- "**.py"
- ".github/workflows/tests_mergin_db_sync.yaml"

env:
TEST_GEODIFF_EXE: geodiff
TEST_DB_CONNINFO: host=localhost dbname=test_db user=postgres password=postgres port=5432
TEST_MERGIN_URL: https://test.dev.merginmaps.com
TEST_API_USERNAME: test_db_sync
TEST_API_PASSWORD: ${{ secrets.TEST_API_PASSWORD }}
TEST_API_WORKSPACE: test-db-sync

jobs:

Tests-for-Mergin-DB-Sync:

runs-on: ubuntu-latest

services:
postgres:
image: postgis/postgis:latest
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: test_db
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

steps:

- name: Install Geodiff
run: |
sudo apt-get install libsqlite3-dev libpq-dev
git clone https://github.com/MerginMaps/geodiff.git
cd geodiff
mkdir build && cd build
cmake -DWITH_POSTGRESQL=TRUE ../geodiff
sudo make install
sudo cp geodiff /usr/local/bin

- name: Check Geodiff version
run: geodiff version

- name: Install Python dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install mergin-client pytest pytest-cov dynaconf psycopg2

- name: Checkout
uses: actions/checkout@v2

- name: Run tests
run: |
pytest test --cov=. --cov-report=term-missing:skip-covered -vv
4 changes: 2 additions & 2 deletions test/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,12 @@ def test_init_from_gpkg_with_incomplete_dir(mc: MerginClient):
source_gpkg_path = os.path.join(TEST_DATA_DIR, 'base.gpkg')
init_project_dir = os.path.join(TMP_DIR, project_name + '_dbsync', project_name)
init_sync_from_geopackage(mc, project_name, source_gpkg_path)
assert os.listdir(init_project_dir) == ['test_sync.gpkg', '.mergin']
assert set(os.listdir(init_project_dir)) == set(['test_sync.gpkg', '.mergin'])
shutil.rmtree(init_project_dir) # Remove dir with content
os.makedirs(init_project_dir) # Recreate empty project working dir
assert os.listdir(init_project_dir) == []
dbsync_init(mc, from_gpkg=True)
assert os.listdir(init_project_dir) == ['test_sync.gpkg', '.mergin']
assert set(os.listdir(init_project_dir)) == set(['test_sync.gpkg', '.mergin'])


def test_basic_pull(mc: MerginClient):
Expand Down
4 changes: 0 additions & 4 deletions test/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,3 @@ def test_config():
config.update({'CONNECTIONS': [{"driver": "postgres", "conn_info": "", "modified": "mergin_main", "base": "mergin_base", "mergin_project": "john/dbsync", "sync_file": "sync.gpkg", "skip_tables":""}]})
validate_config(config)

_reset_config()
with pytest.raises(ConfigError, match="Config error: Ignored tables list can not be empty"):
config.update({'CONNECTIONS': [{"driver": "postgres", "conn_info": "", "modified": "mergin_main", "base": "mergin_base", "mergin_project": "john/dbsync", "sync_file": "sync.gpkg", "skip_tables":[]}]})
validate_config(config)