<commit_before>{ system ? builtins.currentSystem,
  config ? {},
  pkgs ? import ../.. { inherit system config; }
}:

with import ../lib/testing.nix { inherit system pkgs; };
with pkgs.lib;

let
  redmineTest = package: makeTest {
    machine =
      { config, pkgs, ... }:
      { services.mysql.enable = true;
        services.mysql.package = pkgs.mariadb;
        services.mysql.ensureDatabases = [ "redmine" ];
        services.mysql.ensureUsers = [
          { name = "redmine";
            ensurePermissions = { "redmine.*" = "ALL PRIVILEGES"; };
          }
        ];

        services.redmine.enable = true;
        services.redmine.package = package;
        services.redmine.database.socket = "/run/mysqld/mysqld.sock";
        services.redmine.plugins = {
          redmine_env_auth = pkgs.fetchurl {
            url = https://github.com/Intera/redmine_env_auth/archive/0.7.zip;
            sha256 = "1xb8lyarc7mpi86yflnlgyllh9hfwb9z304f19dx409gqpia99sc";
          };
        };
        services.redmine.themes = {
          dkuk-redmine_alex_skin = pkgs.fetchurl {
            url = https://bitbucket.org/dkuk/redmine_alex_skin/get/1842ef675ef3.zip;
            sha256 = "0hrin9lzyi50k4w2bd2b30vrf1i4fi1c0gyas5801wn8i7kpm9yl";
          };
        };
      };

    testScript = ''
      startAll;

      $machine->waitForUnit('redmine.service');
      $machine->waitForOpenPort('3000');
      $machine->succeed("curl --fail http://localhost:3000/");
    '';
  };
in
{
  redmine_3 = redmineTest pkgs.redmine // {
    name = "redmine_3";
    meta.maintainers = [ maintainers.aanderse ];
  };

  redmine_4 = redmineTest pkgs.redmine_4 // {
    name = "redmine_4";<commit_msg>nixos/redmine: test configuration with postgresql as well as mysql<commit_after>{ system ? builtins.currentSystem,
  config ? {},
  pkgs ? import ../.. { inherit system config; }
}:

with import ../lib/testing.nix { inherit system pkgs; };
with pkgs.lib;

let
  mysqlTest = package: makeTest {
    machine =
      { config, pkgs, ... }:
      { services.mysql.enable = true;
        services.mysql.package = pkgs.mariadb;
        services.mysql.ensureDatabases = [ "redmine" ];
        services.mysql.ensureUsers = [
          { name = "redmine";
            ensurePermissions = { "redmine.*" = "ALL PRIVILEGES"; };
          }
        ];

        services.redmine.enable = true;
        services.redmine.package = package;
        services.redmine.database.type = "mysql2";
        services.redmine.database.socket = "/run/mysqld/mysqld.sock";
        services.redmine.plugins = {
          redmine_env_auth = pkgs.fetchurl {
            url = https://github.com/Intera/redmine_env_auth/archive/0.7.zip;
            sha256 = "1xb8lyarc7mpi86yflnlgyllh9hfwb9z304f19dx409gqpia99sc";
          };
        };
        services.redmine.themes = {
          dkuk-redmine_alex_skin = pkgs.fetchurl {
            url = https://bitbucket.org/dkuk/redmine_alex_skin/get/1842ef675ef3.zip;
            sha256 = "0hrin9lzyi50k4w2bd2b30vrf1i4fi1c0gyas5801wn8i7kpm9yl";
          };
        };
      };

    testScript = ''
      startAll;
      $machine->waitForUnit('redmine.service');
      $machine->waitForOpenPort('3000');
      $machine->succeed("curl --fail http://localhost:3000/");
    '';
  };

  pgsqlTest = package: makeTest {
    machine =
      { config, pkgs, ... }:
      { services.postgresql.enable = true;
        services.postgresql.ensureDatabases = [ "redmine" ];
        services.postgresql.ensureUsers = [
          { name = "redmine";
            ensurePermissions = { "DATABASE redmine" = "ALL PRIVILEGES"; };
          }
        ];

        services.redmine.enable = true;
        services.redmine.package = package;
        services.redmine.database.type = "postgresql";
        services.redmine.database.host = "";
        services.redmine.database.port = 5432;
        services.redmine.plugins = {
          redmine_env_auth = pkgs.fetchurl {
            url = https://github.com/Intera/redmine_env_auth/archive/0.7.zip;
            sha256 = "1xb8lyarc7mpi86yflnlgyllh9hfwb9z304f19dx409gqpia99sc";
          };
        };
        services.redmine.themes = {
          dkuk-redmine_alex_skin = pkgs.fetchurl {
            url = https://bitbucket.org/dkuk/redmine_alex_skin/get/1842ef675ef3.zip;
            sha256 = "0hrin9lzyi50k4w2bd2b30vrf1i4fi1c0gyas5801wn8i7kpm9yl";
          };
        };
      };

    testScript = ''
      startAll;
      $machine->waitForUnit('redmine.service');
      $machine->waitForOpenPort('3000');
      $machine->succeed("curl --fail http://localhost:3000/");
    '';
  };
in
{
  v3-mysql = mysqlTest pkgs.redmine // {
    name = "v3-mysql";
    meta.maintainers = [ maintainers.aanderse ];
  };

  v4-mysql = mysqlTest pkgs.redmine_4 // {
    name = "v4-mysql";
    meta.maintainers = [ maintainers.aanderse ];
  };

  v4-pgsql = pgsqlTest pkgs.redmine_4 // {
    name = "v4-pgsql";
{'fraction_non_alphanumeric': 0.13481089873932492, 'fraction_numerical': 0.040870272468483126, 'mean_word_length': 2.231931668856767, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3271969', 'n_tokens_mistral': 1810, 'n_tokens_neox': 1673, 'n_words': 218}