1
0
forked from extern/nix-config

tests: Complete migration to TypeScript/Deno

Well, that was easy.
This commit is contained in:
Donovan Glover 2023-08-31 11:48:25 -04:00
parent 0976968977
commit 0f9ea294c2
No known key found for this signature in database
GPG Key ID: EA7408A77AE1BE65
2 changed files with 7 additions and 33 deletions

View File

@ -1,27 +0,0 @@
require "spec"
def check_top_level_imports(directory)
describe "./#{directory}/default.nix" do
it "imports all modules in ./#{directory}/", tags: "local" do
all_modules = Dir.children(directory)
all_modules.delete("default.nix")
modules = File.read("./#{directory}/default.nix")
all_modules.each do |current_module|
modules.includes?("./#{current_module}").should be_true
end
end
it "only imports modules that exist in ./#{directory}/", tags: "local" do
all_modules = Dir.children(directory)
all_modules.delete("default.nix")
File.each_line("./#{directory}/default.nix") do |line|
if line.includes? "./"
imported_file = line.lstrip(' ').lstrip("./")
all_modules.includes?(imported_file).should be_true
end
end
end
end
end

View File

@ -32,14 +32,15 @@ async function assertAllModulesInDirectory(directory: string) {
const files = await getFilesInDirectory(`./${directory}`) const files = await getFilesInDirectory(`./${directory}`)
const imports = await getImportsInFile(`./${directory}/default.nix`) const imports = await getImportsInFile(`./${directory}/default.nix`)
console.log(files)
console.log(imports)
for (const file of files) { for (const file of files) {
assert(imports.includes(file)) assert(imports.includes(file))
} }
} }
Deno.test("imports all modules in ./packages", async () => { const dirs = ["containers", "home", "modules", "overlays", "packages", "specializations"]
await assertAllModulesInDirectory("packages")
}) for (const dir of dirs) {
Deno.test(`imports all modules in ./${dir}`, async () => {
await assertAllModulesInDirectory(dir)
})
}