From 78022f55b8d452ab10ceeb584a8499146e5097c0 Mon Sep 17 00:00:00 2001 From: Rylan Polster Date: Sat, 16 Dec 2023 20:37:01 -0500 Subject: [PATCH] Update livecheck test fixtures to use `deprecate!` and `disable!` --- Library/Homebrew/test/cask/audit_spec.rb | 20 +++++++++++++++---- ...e.rb => livecheck-deprecated-reference.rb} | 12 +++++------ .../Casks/livecheck/livecheck-deprecated.rb | 16 +++++++++++++++ .../livecheck/livecheck-disabled-reference.rb | 18 +++++++++++++++++ ...-discontinued.rb => livecheck-disabled.rb} | 16 +++++++-------- 5 files changed, 63 insertions(+), 19 deletions(-) rename Library/Homebrew/test/support/fixtures/cask/Casks/livecheck/{livecheck-discontinued-reference.rb => livecheck-deprecated-reference.rb} (58%) create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/livecheck/livecheck-deprecated.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/livecheck/livecheck-disabled-reference.rb rename Library/Homebrew/test/support/fixtures/cask/Casks/livecheck/{livecheck-discontinued.rb => livecheck-disabled.rb} (61%) diff --git a/Library/Homebrew/test/cask/audit_spec.rb b/Library/Homebrew/test/cask/audit_spec.rb index 73d845e470d318..d579af0923a146 100644 --- a/Library/Homebrew/test/cask/audit_spec.rb +++ b/Library/Homebrew/test/cask/audit_spec.rb @@ -529,14 +529,26 @@ def tmp_cask(name, text) it { is_expected.not_to error_with(message) } end - context "when the Cask is discontinued" do - let(:cask_token) { "livecheck/livecheck-discontinued" } + context "when the Cask is deprecated" do + let(:cask_token) { "livecheck/livecheck-deprecated" } it { is_expected.not_to error_with(message) } end - context "when the Cask has a livecheck block referencing a discontinued Cask" do - let(:cask_token) { "livecheck/livecheck-discontinued-reference" } + context "when the Cask has a livecheck block referencing a deprecated Cask" do + let(:cask_token) { "livecheck/livecheck-deprecated-reference" } + + it { is_expected.not_to error_with(message) } + end + + context "when the Cask is disabled" do + let(:cask_token) { "livecheck/livecheck-disabled" } + + it { is_expected.not_to error_with(message) } + end + + context "when the Cask has a livecheck block referencing a disabled Cask" do + let(:cask_token) { "livecheck/livecheck-disabled-reference" } it { is_expected.not_to error_with(message) } end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/livecheck/livecheck-discontinued-reference.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/livecheck/livecheck-deprecated-reference.rb similarity index 58% rename from Library/Homebrew/test/support/fixtures/cask/Casks/livecheck/livecheck-discontinued-reference.rb rename to Library/Homebrew/test/support/fixtures/cask/Casks/livecheck/livecheck-deprecated-reference.rb index ce833b560cc160..47ba962ccb14e6 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/livecheck/livecheck-discontinued-reference.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/livecheck/livecheck-deprecated-reference.rb @@ -1,17 +1,17 @@ -cask "livecheck-discontinued-reference" do +cask "livecheck-deprecated-reference" do version "1.2.3" sha256 "8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b" # This cask is used in --online tests, so we use fake URLs to avoid impacting # real servers. The URL paths are specific enough that they'll be # understandable if they appear in local server logs. - url "http://localhost/homebrew/test/cask/audit/livecheck/discontinued-#{version}.dmg" - name "Discontinued Reference" - desc "Cask for testing a livecheck reference to a discontinued cask" - homepage "http://localhost/homebrew/test/cask/audit/livecheck/discontinued" + url "http://localhost/homebrew/test/cask/audit/livecheck/deprecated-#{version}.dmg" + name "Deprecated Reference" + desc "Cask for testing a livecheck reference to a deprecated cask" + homepage "http://localhost/homebrew/test/cask/audit/livecheck/deprecated" livecheck do - cask "livecheck/livecheck-discontinued" + cask "livecheck/livecheck-deprecated" end app "TestCask.app" diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/livecheck/livecheck-deprecated.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/livecheck/livecheck-deprecated.rb new file mode 100644 index 00000000000000..3b748849912688 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/livecheck/livecheck-deprecated.rb @@ -0,0 +1,16 @@ +cask "livecheck-deprecated" do + version "1.2.3" + sha256 "8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b" + + # This cask is used in --online tests, so we use fake URLs to avoid impacting + # real servers. The URL paths are specific enough that they'll be + # understandable if they appear in local server logs. + url "http://localhost/homebrew/test/cask/audit/livecheck/deprecated-#{version}.dmg" + name "Deprecated" + desc "Cask for testing deprecated in livecheck" + homepage "http://localhost/homebrew/test/cask/audit/livecheck/deprecated" + + deprecate! date: "2023-01-01", because: :discontinued + + app "TestCask.app" +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/livecheck/livecheck-disabled-reference.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/livecheck/livecheck-disabled-reference.rb new file mode 100644 index 00000000000000..0a926cc525a5db --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/livecheck/livecheck-disabled-reference.rb @@ -0,0 +1,18 @@ +cask "livecheck-disabled-reference" do + version "1.2.3" + sha256 "8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b" + + # This cask is used in --online tests, so we use fake URLs to avoid impacting + # real servers. The URL paths are specific enough that they'll be + # understandable if they appear in local server logs. + url "http://localhost/homebrew/test/cask/audit/livecheck/disabled-#{version}.dmg" + name "Disabled Reference" + desc "Cask for testing a livecheck reference to a disabled cask" + homepage "http://localhost/homebrew/test/cask/audit/livecheck/disabled" + + livecheck do + cask "livecheck/livecheck-disabled" + end + + app "TestCask.app" +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/livecheck/livecheck-discontinued.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/livecheck/livecheck-disabled.rb similarity index 61% rename from Library/Homebrew/test/support/fixtures/cask/Casks/livecheck/livecheck-discontinued.rb rename to Library/Homebrew/test/support/fixtures/cask/Casks/livecheck/livecheck-disabled.rb index 9ecf72b7a5eec5..57982f3f9f20e5 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/livecheck/livecheck-discontinued.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/livecheck/livecheck-disabled.rb @@ -1,18 +1,16 @@ -cask "livecheck-discontinued" do +cask "livecheck-disabled" do version "1.2.3" sha256 "8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b" # This cask is used in --online tests, so we use fake URLs to avoid impacting # real servers. The URL paths are specific enough that they'll be # understandable if they appear in local server logs. - url "http://localhost/homebrew/test/cask/audit/livecheck/discontinued-#{version}.dmg" - name "Discontinued" - desc "Cask for testing discontinued in livecheck" - homepage "http://localhost/homebrew/test/cask/audit/livecheck/discontinued" + url "http://localhost/homebrew/test/cask/audit/livecheck/disabled-#{version}.dmg" + name "Disabled" + desc "Cask for testing disabled in livecheck" + homepage "http://localhost/homebrew/test/cask/audit/livecheck/disabled" - app "TestCask.app" + disable! date: "2023-01-01", because: :discontinued - caveats do - discontinued - end + app "TestCask.app" end