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