tests: Only import modules that exist

This commit is contained in:
Donovan Glover 2023-06-10 09:27:36 -04:00
parent ad377d14fa
commit 36ddba7e9b
No known key found for this signature in database
GPG Key ID: EA7408A77AE1BE65

View File

@ -5,7 +5,7 @@ require "./spec_helper"
hint = ""
describe "./modules/default.nix" do
it "imports all modules" do
it "imports all modules in directory" do
all_modules = Dir.children("modules")
all_modules.delete("default.nix")
modules = File.read("./modules/default.nix")
@ -17,6 +17,21 @@ describe "./modules/default.nix" do
hint = ""
end
it "only imports modules that exist" do
all_modules = Dir.children("modules")
all_modules.delete("default.nix")
File.each_line("./modules/default.nix") do |line|
if line.includes? "./"
imported_file = line.lstrip(' ').lstrip("./")
hint = "./#{imported_file} was imported but doesn't exist in directory ./modules/."
all_modules.includes?(imported_file).should be_true
end
end
hint = ""
end
end
describe "./overlays/joshuto/default.nix" do