tests: add option test.stubs

This option provides a more convenient way to overlay dummy packages.
It also adds a function `config.lib.test.mkStubPackage` that can,
e.g., be used for `package` options.
This commit is contained in:
Robert Helgesson 2021-09-26 11:08:45 +02:00
parent b0651cc217
commit cb09a968e9
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
159 changed files with 753 additions and 981 deletions

View file

@ -1,4 +1,5 @@
{ pkgs, ... }:
let
inherit (pkgs.stdenv.hostPlatform) isDarwin;
@ -7,13 +8,11 @@ let
else
".config/rbw/config.json";
in {
config = {
programs.rbw.enable = true;
imports = [ ./rbw-stubs.nix ];
nixpkgs.overlays = [ (import ./overlay.nix) ];
programs.rbw.enable = true;
nmt.script = ''
assertPathNotExists home-files/${path}
'';
};
nmt.script = ''
assertPathNotExists home-files/${path}
'';
}

View file

@ -1,12 +0,0 @@
self: super: {
rbw = self.writeScriptBin "dummy-rbw" "";
pinentry = {
gnome3 = self.writeScriptBin "pinentry-gnome3" "" // {
outPath = "@pinentry-gnome3@";
};
gtk2 = self.writeScriptBin "pinentry-gtk2" "" // {
outPath = "@pinentry-gtk2@";
};
flavors = [ "gnome3" "gtk2" ];
};
}

View file

@ -0,0 +1,16 @@
{ config, ... }:
{
test.stubs.rbw = { };
nixpkgs.overlays = [
(self: super: {
pinentry = {
gnome3 =
config.lib.test.mkStubPackage { outPath = "@pinentry-gnome3@"; };
gtk2 = config.lib.test.mkStubPackage { outPath = "@pinentry-gtk2@"; };
flavors = [ "gnome3" "gtk2" ];
};
})
];
}

View file

@ -1,4 +1,5 @@
{ pkgs, ... }:
let
inherit (pkgs.stdenv.hostPlatform) isDarwin;
@ -17,23 +18,21 @@ let
}
'';
in {
config = {
programs.rbw = {
enable = true;
settings = {
email = "name@example.com";
base_url = "bitwarden.example.com";
identity_url = "identity.example.com";
lock_timeout = 300;
pinentry = "gnome3";
};
imports = [ ./rbw-stubs.nix ];
programs.rbw = {
enable = true;
settings = {
email = "name@example.com";
base_url = "bitwarden.example.com";
identity_url = "identity.example.com";
lock_timeout = 300;
pinentry = "gnome3";
};
nixpkgs.overlays = [ (import ./overlay.nix) ];
nmt.script = ''
assertFileExists home-files/${path}
assertFileContent home-files/${path} '${expected}'
'';
};
nmt.script = ''
assertFileExists home-files/${path}
assertFileContent home-files/${path} '${expected}'
'';
}

View file

@ -1,4 +1,5 @@
{ pkgs, ... }:
let
inherit (pkgs.stdenv.hostPlatform) isDarwin;
@ -17,17 +18,15 @@ let
}
'';
in {
config = {
programs.rbw = {
enable = true;
settings = { email = "name@example.com"; };
};
imports = [ ./rbw-stubs.nix ];
nixpkgs.overlays = [ (import ./overlay.nix) ];
nmt.script = ''
assertFileExists home-files/${path}
assertFileContent home-files/${path} '${expected}'
'';
programs.rbw = {
enable = true;
settings = { email = "name@example.com"; };
};
nmt.script = ''
assertFileExists home-files/${path}
assertFileContent home-files/${path} '${expected}'
'';
}