tests: Add test for rofi overlay

This commit is contained in:
Donovan Glover 2023-06-09 09:06:04 -04:00
parent 176f59f3bd
commit 59c19f1e7c
No known key found for this signature in database
GPG Key ID: EA7408A77AE1BE65
2 changed files with 23 additions and 11 deletions

View File

@ -1,7 +1,6 @@
require "spec" require "spec"
require "colorize" require "colorize"
require "http/client" require "./spec_helper"
require "json"
hint = "" hint = ""
@ -22,16 +21,13 @@ end
describe "./overlays/joshuto/default.nix" do describe "./overlays/joshuto/default.nix" do
it "uses the latest joshuto commit" do it "uses the latest joshuto commit" do
response = HTTP::Client.get "https://api.github.com/repos/kamiyaa/joshuto/branches/main" check_latest_commit("kamiyaa/joshuto", branch: "main")
response.status_code.should eq(200) end
json = JSON.parse(response.body) end
File.read_lines("./overlays/joshuto/default.nix").each do |line| describe "./overlays/rofi/default.nix" do
if line.includes? "version =" it "uses the latest rofi-wayland commit" do
nix_hash = line.split('"')[1] check_latest_commit("lbonn/rofi", branch: "wayland")
json["commit"]["sha"].should eq(nix_hash)
end
end
end end
end end

16
tests/spec_helper.cr Normal file
View File

@ -0,0 +1,16 @@
require "spec"
require "http/client"
require "json"
def check_latest_commit(repository, branch = "master")
response = HTTP::Client.get "https://api.github.com/repos/#{repository}/branches/#{branch}"
response.status_code.should eq(200)
json = JSON.parse(response.body)
File.read_lines("./overlays/#{repository.split("/")[1]}/default.nix").each do |line|
if line.includes? "version ="
nix_hash = line.split('"')[1]
json["commit"]["sha"].should eq(nix_hash)
end
end
end