Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AwesomeSpawn spec failures #238

Merged
merged 1 commit into from
Feb 8, 2024
Merged
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
4 changes: 2 additions & 2 deletions spec/hosts_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,13 @@
end

it "returns the hostname" do
result = AwesomeSpawn::CommandResult.new("", TEST_HOSTNAME, nil, 0)
result = AwesomeSpawn::CommandResult.new("", TEST_HOSTNAME, "", 55, 0)
expect(AwesomeSpawn).to receive(:run).with(*spawn_args).and_return(result)
expect(@instance.hostname).to eq(TEST_HOSTNAME)
end

it "returns nil when the command fails" do
result = AwesomeSpawn::CommandResult.new("", "", "An error has happened", 1)
result = AwesomeSpawn::CommandResult.new("", "", "An error has happened", 55, 1)
expect(AwesomeSpawn).to receive(:run).with(*spawn_args).and_return(result)
expect(@instance.hostname).to be_nil
end
Expand Down
2 changes: 1 addition & 1 deletion spec/ip_address_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
IP_OUT

def result(output, exit_status)
AwesomeSpawn::CommandResult.new("", output, "", exit_status)
AwesomeSpawn::CommandResult.new("", output, "", 55, exit_status)
end

describe "#address" do
Expand Down
2 changes: 1 addition & 1 deletion spec/network_interface/network_interface_rh_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def stub_foreach_to_string(string)
end

def result(output, exit_status)
AwesomeSpawn::CommandResult.new("", output, "", exit_status)
AwesomeSpawn::CommandResult.new("", output, "", 55, exit_status)
end

subject(:dhcp_interface) do
Expand Down
2 changes: 1 addition & 1 deletion spec/network_interface_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
end

def result(output, exit_status)
AwesomeSpawn::CommandResult.new("", output, "", exit_status)
AwesomeSpawn::CommandResult.new("", output, "", nil, exit_status)
end

describe "#reload" do
Expand Down
2 changes: 1 addition & 1 deletion spec/rpm_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
straight-forward, and extensible.
EOS
arguments = [described_class.rpm_cmd, :params => {"-qi" => "ruby"}]
result = AwesomeSpawn::CommandResult.new("", data, "", 0)
result = AwesomeSpawn::CommandResult.new("", data, "", 55, 0)
expect(LinuxAdmin::Common).to receive(:run!).with(*arguments).and_return(result)
metadata = described_class.info("ruby")
expect(metadata['name']).to eq('ruby')
Expand Down
10 changes: 4 additions & 6 deletions spec/subscription_manager_spec.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
describe LinuxAdmin::SubscriptionManager do
context "#run!" do
it "raises a CredentialError if the error message contained a credential error" do
result = AwesomeSpawn::CommandResult.new("stuff", "things", "invalid username or password", 1)
result = AwesomeSpawn::CommandResult.new("stuff", "things", "invalid username or password", 55, 1)
err = AwesomeSpawn::CommandResultError.new("things", result)
expect(LinuxAdmin::Common).to receive(:run!).and_raise(err)

expect { subject.run!("stuff") }.to raise_error(LinuxAdmin::CredentialError)
end

it "raises a SubscriptionManagerError if the error message does not contain a credential error" do
result = AwesomeSpawn::CommandResult.new("stuff", "things", "not a credential error", 1)
result = AwesomeSpawn::CommandResult.new("stuff", "things", "not a credential error", 55, 1)
err = AwesomeSpawn::CommandResultError.new("things", result)
expect(LinuxAdmin::Common).to receive(:run!).and_raise(err)

Expand Down Expand Up @@ -205,12 +205,10 @@

it "with invalid credentials" do
run_options = ["subscription-manager orgs", {:params => {"--username=" => "BadUser", "--password=" => "BadPass"}}]
result = AwesomeSpawn::CommandResult.new("", "", "Invalid username or password. To create a login, please visit https://www.redhat.com/wapps/ugc/register.html", 55, 255)
error = AwesomeSpawn::CommandResultError.new(
"",
double(
:error => "Invalid username or password. To create a login, please visit https://www.redhat.com/wapps/ugc/register.html",
:exit_status => 255
)
result
)
expect(AwesomeSpawn).to receive(:run!).once.with(*run_options).and_raise(error)
expect { described_class.new.organizations({:username => "BadUser", :password => "BadPass"}) }.to raise_error(LinuxAdmin::CredentialError)
Expand Down
4 changes: 2 additions & 2 deletions spec/time_date_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

def timedatectl_result
output = File.read(Pathname.new(data_file_path("time_date/timedatectl_output")))
AwesomeSpawn::CommandResult.new("", output, "", 0)
AwesomeSpawn::CommandResult.new("", output, "", 55, 0)
end

describe ".system_timezone_detailed" do
Expand Down Expand Up @@ -56,7 +56,7 @@ def timedatectl_result
RUN_COMMAND,
:params => ["list-timezones"]
]
result = AwesomeSpawn::CommandResult.new("", timezones, "", 0)
result = AwesomeSpawn::CommandResult.new("", timezones, "", 55, 0)
expect(AwesomeSpawn).to receive(:run!).with(*awesome_spawn_args).and_return(result)
expect(described_class.timezones).to eq(timezones.split("\n"))
end
Expand Down
6 changes: 3 additions & 3 deletions spec/yum_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,18 @@
context ".update" do
it "no arguments" do
expect(LinuxAdmin::Common).to receive(:run!).once.with("yum -y update", :params => nil)
.and_return(AwesomeSpawn::CommandResult.new("", "", "", 0))
.and_return(AwesomeSpawn::CommandResult.new("", "", "", 55, 0))
described_class.update
end

it "with arguments" do
expect(LinuxAdmin::Common).to receive(:run!).once.with("yum -y update", :params => {nil => ["1 2", "3"]})
.and_return(AwesomeSpawn::CommandResult.new("", "", "", 0))
.and_return(AwesomeSpawn::CommandResult.new("", "", "", 55, 0))
described_class.update("1 2", "3")
end

it "with bad arguments" do
error = AwesomeSpawn::CommandResult.new("", "Loaded plugins: product-id\nNo Packages marked for Update\n", "Blah blah ...\nNo Match for argument: \n", 0)
error = AwesomeSpawn::CommandResult.new("", "Loaded plugins: product-id\nNo Packages marked for Update\n", "Blah blah ...\nNo Match for argument: \n", 55, 0)
expect(LinuxAdmin::Common).to receive(:run!).once
.with("yum -y update", :params => {nil => [""]}).and_return(error)
expect { described_class.update("") }.to raise_error(AwesomeSpawn::CommandResultError)
Expand Down