From f44f735b60e4f4ff0954c9369cf18d28d8fea230 Mon Sep 17 00:00:00 2001 From: Adam Focht Date: Mon, 1 Aug 2022 10:58:59 -0400 Subject: [PATCH 1/2] Complete options for status command. --- lib/rhelm/subcommand/status.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/rhelm/subcommand/status.rb b/lib/rhelm/subcommand/status.rb index 8fe6a70..b772ad3 100644 --- a/lib/rhelm/subcommand/status.rb +++ b/lib/rhelm/subcommand/status.rb @@ -6,12 +6,18 @@ module Subcommand ## docs: https://helm.sh/docs/helm/helm_status/ class Status < Base attr_reader :release_name, + :output, + :revision, + :show_desc, :help def initialize(release_name, options = {}) super(options) @release_name = release_name + @output = options[:output] + @revision = options[:revision] + @show_desc = options[:show_desc] @help = options[:help] end @@ -34,6 +40,9 @@ def exists? def cli_args super.tap do |args| args << '--help' if help + args << ['--output', output] if output + args << ['--revision', revision] if revision + args << '--show-desc' if show_desc args << release_name end.flatten From 820a33a2dd462cf22ddd3a27b3dc41a8610fc209 Mon Sep 17 00:00:00 2001 From: Adam Focht Date: Mon, 1 Aug 2022 12:32:41 -0400 Subject: [PATCH 2/2] Add status command testing. --- test/unit/subcommand/status_test.rb | 37 +++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 test/unit/subcommand/status_test.rb diff --git a/test/unit/subcommand/status_test.rb b/test/unit/subcommand/status_test.rb new file mode 100644 index 0000000..387a20d --- /dev/null +++ b/test/unit/subcommand/status_test.rb @@ -0,0 +1,37 @@ +require "test_helper" +require "rhelm/subcommand/status" + +describe Rhelm::Subcommand::Status do + describe "with a subject" do + let(:subject) do + ::Rhelm::Subcommand::Status.new( + "example-release", + output: 'json', + revision: 2, + show_desc: true + ) + end + + describe "#subject_name" do + it "returns the string 'status'" do + assert_equal subject.subcommand_name, "status" + end + end + + describe "#full_cli_call" do + it "returns the full command array" do + command = subject.full_cli_call + output_index = command.index("--output") + revision_index = command.index("--revision") + + assert_equal command[0], "helm" + assert_equal command[1], "status" + assert output_index + assert_equal command[output_index + 1], "json" + assert revision_index + assert_equal command[revision_index + 1], "2" + assert_includes command, "--show-desc" + end + end + end +end