From 59c19f1e7c74b2bfe2bf8c3f4af7d42a4655a96e Mon Sep 17 00:00:00 2001 From: Donovan Glover Date: Fri, 9 Jun 2023 09:06:04 -0400 Subject: [PATCH] tests: Add test for rofi overlay --- tests/main.cr | 18 +++++++----------- tests/spec_helper.cr | 16 ++++++++++++++++ 2 files changed, 23 insertions(+), 11 deletions(-) create mode 100644 tests/spec_helper.cr diff --git a/tests/main.cr b/tests/main.cr index 919d9adf..7c5efba2 100644 --- a/tests/main.cr +++ b/tests/main.cr @@ -1,7 +1,6 @@ require "spec" require "colorize" -require "http/client" -require "json" +require "./spec_helper" hint = "" @@ -22,16 +21,13 @@ end describe "./overlays/joshuto/default.nix" do it "uses the latest joshuto commit" do - response = HTTP::Client.get "https://api.github.com/repos/kamiyaa/joshuto/branches/main" - response.status_code.should eq(200) - json = JSON.parse(response.body) + check_latest_commit("kamiyaa/joshuto", branch: "main") + end +end - File.read_lines("./overlays/joshuto/default.nix").each do |line| - if line.includes? "version =" - nix_hash = line.split('"')[1] - json["commit"]["sha"].should eq(nix_hash) - end - end +describe "./overlays/rofi/default.nix" do + it "uses the latest rofi-wayland commit" do + check_latest_commit("lbonn/rofi", branch: "wayland") end end diff --git a/tests/spec_helper.cr b/tests/spec_helper.cr new file mode 100644 index 00000000..aeba6361 --- /dev/null +++ b/tests/spec_helper.cr @@ -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