From 7ca79553f0ba9e2e83d3bad069ba90eb576fd3cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20=C3=81lvaro?= Date: Sat, 6 Feb 2021 21:11:55 +0100 Subject: [PATCH] Add test to check --json=v2 format --- Library/Homebrew/test/cmd/info_spec.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Library/Homebrew/test/cmd/info_spec.rb b/Library/Homebrew/test/cmd/info_spec.rb index 9189b106d9..aaadf55297 100644 --- a/Library/Homebrew/test/cmd/info_spec.rb +++ b/Library/Homebrew/test/cmd/info_spec.rb @@ -6,6 +6,19 @@ require "cmd/info" require "cmd/shared_examples/args_parse" describe "brew info" do + let(:tarball) do + if OS.linux? + TEST_FIXTURE_DIR/"tarballs/testball-0.1-linux.tbz" + else + TEST_FIXTURE_DIR/"tarballs/testball-0.1.tbz" + end + end + let(:expected_output) { + <<~EOS + {"formulae":[{"name":"testball","full_name":"testball","tap":"homebrew/core","oldname":null,"aliases":[],"versioned_formulae":[],"desc":"Some test","license":null,"homepage":"https://brew.sh/testball","versions":{"stable":"0.1","head":null,"bottle":false},"urls":{"stable":{"url":"file://#{tarball}","tag":null,"revision":null}},"revision":0,"version_scheme":0,"bottle":{},"keg_only":false,"bottle_disabled":false,"options":[{"option":"--with-foo","description":"Build with foo"}],"build_dependencies":[],"dependencies":[],"recommended_dependencies":[],"optional_dependencies":[],"uses_from_macos":[],"requirements":[],"conflicts_with":[],"caveats":null,"installed":[],"linked_keg":null,"pinned":false,"outdated":false,"deprecated":false,"deprecation_date":null,"deprecation_reason":null,"disabled":false,"disable_date":null,"disable_reason":null}],"casks":[]} + EOS + } + it_behaves_like "parseable arguments" it "prints as json with the --json=v1 flag", :integration_test do @@ -26,6 +39,13 @@ describe "brew info" do .and be_a_success end + it "check --json=v2 format", :integration_test do + setup_test_formula "testball" + + expect { brew "info", "testball", "--json=v2" } + .to output(expected_output).to_stdout + end + describe Homebrew do describe "::github_remote_path" do let(:remote) { "https://github.com/Homebrew/homebrew-core" }