Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/rhelm/subcommand/status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
37 changes: 37 additions & 0 deletions test/unit/subcommand/status_test.rb
Original file line number Diff line number Diff line change
@@ -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