at 23.11-pre 2.2 kB view raw
1import ./make-test-python.nix ({ pkgs, lib, ... }: 2 3/* 4 This test suite replaces the typical pytestCheckHook function in 5 sqlite3-to-mysql due to the need of a running mysql instance. 6*/ 7 8{ 9 name = "sqlite3-to-mysql"; 10 meta.maintainers = with lib.maintainers; [ gador ]; 11 12 nodes.machine = { pkgs, ... }: { 13 environment.systemPackages = with pkgs; [ 14 sqlite3-to-mysql 15 # create one coherent python environment 16 (python3.withPackages 17 (ps: sqlite3-to-mysql.propagatedBuildInputs ++ 18 [ 19 python3Packages.pytest 20 python3Packages.pytest-mock 21 python3Packages.pytest-timeout 22 python3Packages.factory_boy 23 python3Packages.docker # only needed so import does not fail 24 sqlite3-to-mysql 25 ]) 26 ) 27 ]; 28 services.mysql = { 29 package = pkgs.mariadb; 30 enable = true; 31 # from https://github.com/techouse/sqlite3-to-mysql/blob/master/tests/conftest.py 32 # and https://github.com/techouse/sqlite3-to-mysql/blob/master/.github/workflows/test.yml 33 initialScript = pkgs.writeText "mysql-init.sql" '' 34 create database test_db DEFAULT CHARACTER SET utf8mb4; 35 create user tester identified by 'testpass'; 36 grant all on test_db.* to tester; 37 create user tester@localhost identified by 'testpass'; 38 grant all on test_db.* to tester@localhost; 39 ''; 40 settings = { 41 mysqld = { 42 character-set-server = "utf8mb4"; 43 collation-server = "utf8mb4_unicode_ci"; 44 log_warnings = 1; 45 }; 46 }; 47 }; 48 }; 49 50 testScript = '' 51 machine.wait_for_unit("mysql") 52 53 machine.succeed( 54 "sqlite3mysql --version | grep ${pkgs.sqlite3-to-mysql.version}" 55 ) 56 57 # invalid_database_name: assert '1045 (28000): Access denied' in "1044 (42000): Access denied [...] 58 # invalid_database_user: does not return non-zero exit for some reason 59 # test_version: has problems importing sqlite3_to_mysql and determining the version 60 machine.succeed( 61 "cd ${pkgs.sqlite3-to-mysql.src} \ 62 && pytest -v --no-docker -k \"not test_invalid_database_name and not test_invalid_database_user and not test_version\"" 63 ) 64 ''; 65})