meta: Add tests

Tests help guarantee that I don't forget to do something that I should
have done, such as importing a certain nix module.
This commit is contained in:
Donovan Glover 2023-06-08 17:14:23 -04:00
parent ac58a29d86
commit d137d3342c
No known key found for this signature in database
GPG Key ID: EA7408A77AE1BE65
2 changed files with 18 additions and 1 deletions

View File

@ -61,7 +61,8 @@ in {
utf16 = "recode utf16..utf8"; # Rarely, some files from Japan are utf16 instead
jp = "LANG=ja_JP.UTF-8 LC_ALL=ja_JP.UTF-8";
vm = "cd ~/nix-config && nixos-rebuild build-vm --flake . && ./result/bin/run-${VARIABLES.hostname}-vm && trash put result ${VARIABLES.hostname}.qcow2";
sw = "cd ~/nix-config && sudo nixos-rebuild switch --flake .";
sw = "cd ~/nix-config && crystal run tests/main.cr --progress && sudo nixos-rebuild switch --flake .";
st = "cd ~/nix-config && crystal run tests/main.cr --progress";
c = "tput reset"; # Clear the terminal completely
e = "exit";

16
tests/main.cr Normal file
View File

@ -0,0 +1,16 @@
require "spec"
require "colorize"
describe "nix-config" do
it "includes all modules" do
all_modules = Dir.children("modules")
all_modules.delete("default.nix")
modules = File.read("./modules/default.nix")
all_modules.each do |current_module|
print "Checking ./modules/#{current_module}...".colorize(:blue)
modules.includes?("./#{current_module}").should be_true
puts "".colorize(:green)
end
end
end